Now that i've finally got some varnish hits on my site i've been doing a bit of testing on my site and am not sure I'm experiencing the full performance benefits of varnish.
My VCL is pretty much as per the example with the respective examples uncommented as needed.
Varnish stat reports an average hit rate of about 0.7 over time.
For anonymous users with the same permissions.
In Firefox i start a browsing session as an anonymous user.
What I am finding is that when i start a new browsing session to my site the initial visit to a page will be a varnish miss but if i refresh the page i will then get a varnish hit. (Status code 304 Not Modified which i believe to be normal behaviour)
I then start another anonymous browsing session using chrome and when i visit that same page i would expect that i should receive the page through varnish but instead the page is a varnish miss and it comes from apache. if i then refresh that page in the same chrome window however it gives me a varnish hit.
So i looked into how this is suppose to work at the top of the example ie.
* 2. Retrieve X-Authcache-Key form the backend and add it onto the request
* ------------------------------------------------------------------------
* The authcache key is a value which is unique for every combination of Drupal
* user roles. The keys of two users are only equal if both of them have the
* exact same combination of user roles and therefore identical permissions.
*
* Authcache Varnish exposes the callback /authcache-varnish-get-key which
* returns the authcache key for the currently logged in user. Except when one
* of the roles is excluded from caching, in that case no key is returned from
* the callback.
So I'm wondering should I be seeing the X-authcache-key in the browsers headers?
Is there anything i can check to see whats going on.
thanks in advance again for your help
Comments
Comment #1
znerol CreditAttribution: znerol commentedNo, this is a request header, added by Varnish when forwarding a request to the backend.
Checkout varnishlog, if you want to analyze backend connections, try
-b
.Comment #2
Colin @ PCMarket CreditAttribution: Colin @ PCMarket commentedThanks znerol
What am i looking for in particular in the varnishlog
Is what i described expected behaviour or an indication that something is misconfigured?
Comment #3
znerol CreditAttribution: znerol commentedIf your cache is warm (i.e. it contains an entry for a particular page), then the first page request of a newly opened browser should result in a cache hit.
Comment #4
Colin @ PCMarket CreditAttribution: Colin @ PCMarket commentedWhat would be the likely cause of a page with a cache entry not being served to a newly opened browser?
i have in my settings.php
// Expiration of cached pages.
$conf['page_cache_maximum_age'] = 21660;
// minimum cache lifetime.
$conf['cache_lifetime'] = 30;
not sure if this makes a difference.
Comment #5
znerol CreditAttribution: znerol commentedDo you get a cache-HIT when you test with something different than a browser? E.g. with isvarnishworking.com?
Comment #6
Colin @ PCMarket CreditAttribution: Colin @ PCMarket commentedon isvarnishworking i only get a cache hit on refresh
Comment #7
znerol CreditAttribution: znerol commentedI do not understand that. iswarnishworking will start an entirely new request (no cookies, nothing) everytime you submit the page. Could you please post the output from your first and from the second attempt here?
Comment #8
Colin @ PCMarket CreditAttribution: Colin @ PCMarket commentedOutput from entering URL into isvarnishworking first time
And then refresh results
Comment #9
znerol CreditAttribution: znerol commentedWhen do you clear caches? I.e., how often do you run cron?
Comment #10
znerol CreditAttribution: znerol commentedSee also Authcache 2 tuning guide - optimize cache-hit ratio, especially the part about cron.
Comment #11
Colin @ PCMarket CreditAttribution: Colin @ PCMarket commentedi don't clear caches very often
cron is currently set to run every 3 hours
Comment #12
znerol CreditAttribution: znerol commentedAccording to #8 I believe that Authcache/Varnish is working as intended. For further tuning please consider the following things:
Double check your Varnish (the Drupal module) settings, especially whether or not the page cache is flushed during cron runs and also the cache clearing mode: Drupal Default means that the cache is cleared whenever a node is edited, or similar actions happen on the page. If edits happen frequently on your site, consider setting up the Cache Expiration module and switch to Selective mode.
You currently deliver pages with
Cache-Control: public, max-age=21660
to the client. This means that browsers may cache the response for up to 6 days. For most sites this value is far too high.Both of these points are generic Varnish configuration issues. If you need further support, then you will be better off asking over in the Varnish module issue queue or directly in the Varnish Forums.