skip to Main Content

We’ve just launched a fairly barebones HTML and JS website, that needs frequent changing that needs to propagate to users as quickly as possible – we’re having issues with having to ask users to clear their caches, and want to find out if there is a way within the HTML file itself, or the Apache web server it runs on, to have a browser recache the page after a change has occured, but only for the first time it’s loaded. Is there any way of doing this?

We’ve already rejected the idea of changing the webaddress, due to the frequency of changes being pushed it would be impractical.

We’re looking into HTTP code 205, which could be sent from our webserver and update a user’s status on the database (we do have user accounts stored that could be used to apply this change) but we’re unsure as to whether this could be implemented easily, especially if the pages that change are more overarching in resources linked to by the document, which are what changes most often

Our backend is ExpressJS, however due to CORS on our requests we seem unable to redirect (though if resolving that is neccesary I’d be happy to hear it)

I’m aware that location.reload(true) could prompt this, but I’m unsure as to whether doing so would be practical, as we’d have to have this change pushed out.

2

Answers


  1. You’re overthinking it. I suggest using short explicit cache time with mod_expires. If you don’t provide any caching info, browsers will use a heuristic which you may not like.

    Login or Signup to reply.
  2. It may not be straightforward to achieve on-demand cache purge while the webpage is updated given that for you hashed page addresses or Javascript is not an option. I’d suggest looking into cache-control and expires meta tags.

    Examples:

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="max-age=0">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="expires" content="Sun, 23 Apr 2023 1:00:00 GMT">
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search