Author Topic: Varnish Cache Age 0  (Read 1554 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Varnish Cache Age 0
« on: February 22, 2023, 12:56:44 AM »
Dear Forum, I hope that you can help me resolve this ... I have activated Nginx & Varnish & Apache, Website when I CURL returns AGE : 0 and i see that Varnish Cache is serving the site

However the test code <?php
echo rand(1, 99);
?>

returns a different number every time, so even through curl shows varnish in the header, varnish is not caching.

I edited he webserver config for the domain and selected Vanish,  Selected the Wordpress.tpl file, rebuilt config and the site is up and running. I do not know what is missing, I suppose the website could be very busy and filling the cache perhaps too quickly but doubt that.. help would be great, or at least some hints to where I can look

TTP/1.1 200 OK
Server: nginx/1.22.1
Date: Wed, 22 Feb 2023 00:55:24 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 22
Connection: keep-alive
Keep-Alive: timeout=60
Cache-Control: max-age=0
Expires: Wed, 22 Feb 2023 00:55:24 GMT
Content-Encoding: gzip
X-Varnish: 296099
Age: 0
Via: 1.1 varnish (Varnish/5.2)

Offline
***
Re: Varnish Cache Age 0
« Reply #1 on: February 22, 2023, 06:25:35 AM »
and your problem solved ?


if so... can we make it for 1 or 2 days /?

Offline
*
Re: Varnish Cache Age 0
« Reply #2 on: February 22, 2023, 07:54:08 PM »
My problem is not solved, I have varnish enabled but whenever I try the test php page the number is different, meaning the cache is not working.

Still looking for help on how to troubleshoot.

There is a chance that my cache is too small, and the site is too busy so it keeps emptying itself I suppose however I have no clue how to validate that...

anyone????

Offline
***
Re: Varnish Cache Age 0
« Reply #3 on: February 23, 2023, 12:17:18 AM »
My problem is not solved, I have varnish enabled but whenever I try the test php page the number is different, meaning the cache is not working.

Still looking for help on how to troubleshoot.

There is a chance that my cache is too small, and the site is too busy so it keeps emptying itself I suppose however I have no clue how to validate that...

anyone? ???


the random php is only one way to check varnish ....

in fact if you type https://domain.tld/files.php? it will request new result

Offline
*
Re: Varnish Cache Age 0
« Reply #4 on: February 25, 2023, 01:41:51 AM »
the random PHP does not work. It returns a new number every time, that means varnish is not working.
This is rand.php
<?php
echo rand(1, 99);
?>
And the results are "random" , if the cache was working, they results would not change.

Offline
****
Re: Varnish Cache Age 0
« Reply #5 on: March 11, 2023, 05:08:02 PM »
Are you checking HTTP reply headers?
Quote
What is the purpose of the X-Varnish HTTP header?
The X-Varnish HTTP header allows you to find the correct log-entries for the transaction. For a cache hit, X-Varnish will contain both the ID of the current request and the ID of the request that populated the cache. It makes debugging Varnish a lot easier.