Force pages to auto-refresh - not use their cache

I update my website regularly. It contains images of items which are often changed. I delete the item or replace it with another. How can I force users to use the fresh web page and NOT use the version in their cache. I could ask folk to clear their cache, but many naïve users would not know how. I want it to be automatic to use a fresh copy from the web.

You can use simply use javascript to redirect users from one page to another.
The users will follow the older link but simultaneously they will be redirected to another one.

Use this code for javascript:

<script type="text/javascript">
window.location.href = "your url";
</script>

If you are stil having any problem please reply on the post

Purge all your caches after updating your site using the W3 Total Cache if you’re using wordpress.

I found this thread, using htaccess editing and html tags:

To my knowledge, there is no way to control browser cache from a script on your website. You can only send caching headers when people first access a file which controls for how long the cache is valid. But if you want people to see all changes instantly that way, you would have to (almost) disable all cache, which slows down websites and increases bandwidth and server power usage, so that’s not recommended.

Another solution (which this forum does as well) is to change the file name with every release. For example, instead of always loading styles.css, you could load styles-202006121525.css instead. When publishing the new version, you could change that suffix and update the URLs on your page, which makes browsers think you’re loading a different file.

Some website building systems have this as an option.

4 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.