November 4, 201511 yr Silly question - is there anything that can force a "refresh" of the browser each time someone visits the website and still implement "leverage browser cache" like some tools want or does the former essentially nullify the later? Just curious. Thank you in advance.
November 4, 201511 yr Author For ongoing updates to the site - so the newest information / images / tweeks show up properly. Unfortunately not everyone knows to hit the refresh button on a website. Was just curious is all.
November 4, 201511 yr Edit: Removed my answer because I don't actually understand the question. Edited November 4, 201511 yr by Jack
November 4, 201511 yr Ok I think I've got it. If you mean to swap UI elements out without refreshing the browser, that's quite complex. It's known as hot reloading. A few JS frameworks do this, like React, Angular, and Meteor. If you want to refresh the page so that the user always gets the current CSS, JS, then refreshing alone isn't a guarantee of invalidating the cache. Some implementations cache more aggressively than others, so do some browsers. You would need a way of explicitly forcing the browser to re-cache, and the only way I can think of doing this is to altar the file names of your CSS and JS files (style.css?2), that way the new version overwrites the old. It's not something you would want to do every time, otherwise the user never gets served the cached file. However, it can be useful when you make a load of new changes, and you want to ensure the user isn't getting a broken layout. Regardless of this, the user will still have to refresh to see the new changes. You should avoid adding in scripts that force a browser refresh. It's awkward behaviour, and it doesn't really have any benefit. I would say I'd be surprised if someone left a webpage open expecting changes to come in automatically, but seeing as a lot of websites nowadays utilise real-time services, I can imagine there's someone out there that just expects websites to work like this. I don't think it's anything to be concerned about though, refreshing is an extremely common part of web-browsing, I'd expect just about everyone knows to do it.
November 28, 201510 yr If your site is dynamically generated then you can add a timestamp after each file url as a parameter. For example, "../css/style.css?id=6745734573" each time a request is made to the page a different number should be generated, so the browser see it as a new url and it fetches the url from the server instead of using the file from cache
Create an account or sign in to comment