• Resolved Luke Boobyer

    (@lsbwebdesign)


    I’ve been wondering about the max-age value and how browser cache works exactly.

    My understanding is that max-age defines a unit of time in seconds (relative to the time of the request) for which the response is deemed ‘fresh’.

    This Cache-Control header tells the browser that it can use this file from the
    cache for the next 60 seconds without having to worry about revalidating it.
    Once the 60 seconds is up, the browser will head back to the server to
    revalidate the file.

    The plugins works and the correct headers are showing, but I am a little unsure about the max-age and browser cache behaviour.

    If I view my page once it will be cached in the browser, if I reload the page before the max-age value then shouldn’t it use the cached version in my browser.

    For example css and js files are served from memory cache, shouldn’t that also apply for the html which is also now being cached. So the size being transferred should be 0.

    https://snipboard.io/rkwY2d.jpg

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Luke Boobyer

    (@lsbwebdesign)

    So after a bit more testing this does kind of work, but not as I would expect.

    If I load my page straight away after clearing the full Cloudflare cache, then reload the page before the max-age value then the page is served from my local disk cache https://snipboard.io/nyxO06.jpg
    https://snipboard.io/zwLMOI.jpg

    But if I visit the page outside the max-age value and reload the page, then it is served from Cloudflare by the looks of it:
    https://snipboard.io/L0uH1j.jpg
    https://snipboard.io/PH2paZ.jpg

    Have I misunderstood how max-age should work?

    Plugin Contributor Salvatore Fresta

    (@salvatorefresta)

    Hi @lsbwebdesign,
    the cache-control header setted up by WP Cloudflare Super Page Cache has 2 main values:

    max-age: this is the time to live in seconds for browser cache, and must be greater than zero (at least 1)

    s-max-age: this is the time to live in seconds for the Cloudflare’s cache

    A max-age of 60 means that for the first 60 seconds the page must be loaded from the local disk (your browser cache). If the page doesn’t exists on your local cache, will be loaded from the server that is Cloudflare if it is already on cache (in this case you see cf-status-cache: hit) or from your origin server.

    WP Cloudflare Super Page Cache sets up a cache-control header for HTML pages only, not for static contents, unless you enable the Add browser caching rules for assets option that adds into your htaccess some browser caching rules for css, scripts, fonts and images.

    I hope I have answered your question ??

    Thread Starter Luke Boobyer

    (@lsbwebdesign)

    Thanks yes that answered my question nicely.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘max-age and browser cache’ is closed to new replies.