1

we're using this varnish module http://www.magentocommerce.com/magento-connect/pagecache-powered-by-varnish.html V 3.1.2. With this module comes a default.vcl which really works well out of the box, but there is a part of the sub deliver that I don't get.

When an html object is cacheable, the sub fetch sets http.magicmarker=1

Here's what happens in the sub deliver :

if (resp.http.magicmarker) {
    # Remove the magic marker
    unset resp.http.magicmarker;

    set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    set resp.http.Pragma = "no-cache";
    set resp.http.Expires = "Mon, 31 Mar 2008 10:00:00 GMT";
    set resp.http.Age = "0";
}

Is there a reason to set Cache-Control and Pragma to "no-cache" ?

Here is the full vcl provided with the module : https://gist.github.com/ashsmith/5429365/raw/07f047d679edfdca0a52a62b606e2dd871c360a4/default_3.0.vcl

Thank you for your help

2
  • 1
    Though the context is Magento, this may get more/better answers at serverfault or webmasters on the SE network.
    – benmarks
    May 22, 2013 at 19:28
  • 1
    This only makes sense in a case where you want no client-cached stuff. Because nothing else is affected bythis behavior. I could imagine usage of this to ensure up-to-date javascirpts and images, as not every browser is really accurate in respecting cache lifetimes.
    – tutnix
    Aug 13, 2013 at 6:49

2 Answers 2

1

I have written a Varnish module for Magento, and I assume the author of the VCL is wanting to get the browser to fetch the page each time it is requested, rather than storing a copy of it in the users web browser cache. The VCL is caching the HTML, but instructing the browser not to. A good reason for this is that you want a website to load quick, but you don't want stale or out of date information.

0

This just makes sure that Content with Content-Type ~ "text/html" or Content-Type ~ "text/xml" do not end up in the browser cache. If you go to the page a second time or you reload it, the html is always taken from varnish again. So if you call http://www.code4business.de/projekte/ the second time and you look at your network (press F12 in Chrome or Firefox with Firebug, the Network) you see this:

Varnish Network code4business

Everything comes from the browser cache (not Varnish) except for the html-page. This is what the underneath code is doing. It might be useful is some cases. However, I would hope that your CMS handles it correctly already.

if (resp.http.magicmarker) {
    # Remove the magic marker
    unset resp.http.magicmarker;

    set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    set resp.http.Pragma = "no-cache";
    set resp.http.Expires = "Mon, 31 Mar 2008 10:00:00 GMT";
    set resp.http.Age = "0";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.