Prajithp / ApacheBooster

This project has been taken over by Ndimensionz. New and bug free version of Apachebooster can be downloaded from
http://ndimensionz.com/apachebooster
20 stars 26 forks source link

Age: 0 Varnish is Working - Yes! Sort of! #39

Closed brazildotcom closed 10 years ago

brazildotcom commented 10 years ago

Hi,

According to Is Varnish Working, the content is not being cached by Varnish, can you please provide some [FIX] ?

http://www.isvarnishworking.com/

Yes! Sort of!

Varnish appears to be responding at that url, but the "Age" header is less than 1.

This means that either, 1) you checked right when Varnish cleared it's cache for that url, or 2) for whatever reason Varnish is not actually serving the content for that url from cache.

If it is the former, just check again and see if you get a more solid confirmation.

If it is the latter, perhaps one of the following is happening:

That url is excluded from the cache on purpose in the Varnish vcl file (in which case, yay! It's working.)
The application is sending cache headers that are telling Varnish not to serve that content from cache. This means you'll have to fix the cache headers the application is sending to Varnish. A lot of the time those headers are Cache-Control and/or Expires.
The application is setting a session cookie, which can prevent Varnish from serving content from cache. This means you'll have to update the application and make it not send a session cookie for anonymous traffic.
Internet Ghosts.

And here, for you to ponder further, are the actual headers we received:

The url we checked: domain.com HTTP/1.1 200 OK Server: nginx/1.4.4 Date: Tue, 15 Apr 2014 13:38:37 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Vary: Accept-Encoding Pragma: no-cache Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 X-Pingback: http://domain.com/xmlrpc.php Link: http://domain.com/?p=1165; rel=shortlink Set-Cookie: kpg_stop_spammers_time=1397558186; expires=Tue, 15-Apr-2014 10:37:26 GMT magicmarker: 1 X-Cacheable: YES X-Varnish: 861350089 Age: 0 Via: 1.1 varnish Content-Encoding: gzip

Prajithp commented 10 years ago

Hey,

Can you please confirm the following points, so that I can work accordingly. 1) Is it showing every time? or only for the first request?. 2) let me know your apachebooster version.

Also please note: After the varnish restart or cache purge, the first request will always hit Apache server and you should see Age 0 or cache MISS header. Varnish will put all resources for that URL in cache, after that you can see the modified Age header with HIT.

Btw, I have just modified the existing vcl file to fix the cache issue, is it possible to test the same on your end? If yes, please follow the below steps and let me know the feedback

mv /usr/local/varnish/etc/varnish/default.vcl /usr/local/varnish/etc/varnish/default.vcl_bakk

wget https://raw.githubusercontent.com/Prajithp/ApacheBooster/master/apachebooster/conf/varnishconf/default_dev.vcl -O /usr/local/varnish/etc/varnish/default.vcl

/etc/init.d/varnish restart
williamgomes commented 8 years ago

Hello, I am having a similar problem with something else. Can someone please help me, like where to look to resolve the problem? I am using Varnish on top of Craft CMS and both on two separate server. Thnx in advance.