• Resolved Alwin

    (@wp-opti)


    Question about the Browser static file caching settings:

    If I set the expiration time to 30 days, for example, what happens in the following scenario:

    • A visitor visits my website and the website is stored in his local browser cache (?)
    • After 20 days he visits my website again. Is the 20-day old website from his local browser cache now shown? That would not be convenient because the website maybe changed somewhere in those 20 days..

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support wpmansour

    (@wpmansour)

    When you set the expiration time to 30 days, static files like CSS, JS, or images are cached in the visitor’s browser for that duration. Here’s what happens when the visitor revisits your site after 20 days:

    • If the file hasn’t expired (still within 30 days): The browser will serve the cached version without requesting a new one from the server. This saves bandwidth and improves load time.
    • If the file has changed on the server: The browser compares the file’s version using its Last-Modified or ETag headers (if configured). If a new version is detected (e.g., due to file changes), the browser downloads the updated file, overriding the cached version.

    Hope this helps!

    Thread Starter Alwin

    (@wp-opti)

    Thank you, so if I understand correctly a browser never serve the old (browser) cached version without cheking for a new version first?

    Plugin Support wpmansour

    (@wpmansour)

    You’re correct! Even if the browser has cached the file locally (e.g., within the 30-day expiration period), it will still check with the server to ensure the cached version is up-to-date. This happens via headers like Last-Modified or ETag. If the file hasn’t changed, the browser will use the cached version to save bandwidth and speed up loading. If a new version exists, it will download and replace the old cached file. So, the visitor won’t see an outdated version as long as these headers are correctly configured.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.