Disable Varnish Cache

Status
Not open for further replies.

mtthomps

New Member
Messages
4
Reaction score
0
Points
1
Hello,

How can I verify that Varnish Cache is disabled?

My Virtuemart template seems to have problems with updating the cart. My template designer is telling me that sever cache is causing the problem and is able to run a copy of my site on their server without problems.

I tried disabling cache by adding

Header set Cache-Control "max-age=0, private, no-cache, no-store, must-revalidate"

to .htccess.

I also tried adding (per this post: https://x10hosting.com/community/threads/caching-is-killing-me.194965/#post-934938)

<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>

Neither seems to do anything and I still have my problem.
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi mtthomps,

It looks like Varnish is not caching your website's home page.
Pragma: no-cache
X-Cache: MISS


Please could I have a link to the webpage that is being cached?

Thank you,
 

mtthomps

New Member
Messages
4
Reaction score
0
Points
1
Hi mtthomps,

It looks like Varnish is not caching your website's home page.



Please could I have a link to the webpage that is being cached?

Thank you,

Thanks for the reply Dead-i.

The developer of the template says that server cache is causing the following problem:

Go to any product details page
Add to Cart
Show Cart
change quantity (I think any update would do)
Click update icon
Cart empties (Not Good!)
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi mtthomps,

Thank you for providing me with this. I reproduced the issue, but it appears that each of the requests I made to change the item quantity had the X-Cache header set to MISS. This means that Varnish is not caching the request, and it is retrieving the latest version of the file. I'm not so sure that this is an issue caused by Varnish.

Thank you,
 

mtthomps

New Member
Messages
4
Reaction score
0
Points
1
Thanks D-i. This is good info.

Can you tell me though. I found in the knowledge Base that adding

Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"

to .htaccess disables Varnish cache.

I also read multiple posts here that this setting wasn't working and in one post (referenced above) a user stated that adding:

<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>

did work. This is what's in my .htaccess now.

Do I need this? Or does the [ Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" ] by itself work?

Tx
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

The "Header set" line alone will stop Varnish from caching your webpages, and there shouldn't be any need for a filesMatch block. We have done some extensive testing with Varnish's caching, and we confirmed that this line alone will stop caching. :)

Thank you,
 

webbrewe

Member
Messages
58
Reaction score
3
Points
8
Hi,

I backed up and restored this site to a different (free) hosting provider and the cart functions properly there. Any ideas what the problem could be?

http://www.mtthompson.byethost7.com/

A year late - but just confirming you changed the expiry date in the above?
So:
<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 2084 05:00:00 GMT"
</ifModule>
</filesMatch>
Also noting that the full code above is necessary - the header set alone has never disabled server caching for me in any site.
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
@webbrewe Varnish essentially proxies your connection to the web server, so that it can serve cached versions. When you make a request to your website, your request goes to Varnish. Varnish serves a cached copy if it has one, and if it doesn't, it will download a copy from our web server (Apache) and send it. If Varnish downloads a page and sees a "Cache-Control" header stating it cannot be cached, Varnish will always re-download the webpage, rather than keep it in memory and serve the cached version when possible.

This isn't to be confused with browser caching, in which you might need to set extra headers. For server-side Varnish caching, though, only Cache-Control is needed.

http://x10hosting.com/support/general/varnish-cache
 
Status
Not open for further replies.
Top