No Cache on webpages

Dear Sitepoint community,

I have a number of numbers that I’ve updated, the problem is that by updating the website I have a problem, with returning users seeing a dreadful looking website, due to the cache on the web browsers not being cleared.

Is there some Javascript code or anyother code that will clear the web user previous visit to a new uploaded website?

The website needs to be refreshed when the web page is loading.

Many thanks

Not quite sure what you’re asking. Are you wanting to know if you can clear a user’s cache? The answer is no (that would be bad). You can tell the browser that you don’t want a certain page cached and it might listen to you. Another thing you can do is change the filenames so it has to refresh (a good example of this would be including a version number in your css file name like: main.v1.0.css or using a timestamp or something).

Using the querystring for the version number or timestamp is typically the more accepted solution these days.

e.g., main.css?1.0