Caching

Hi there,

Just started working on a website here myself, very new to it all.
My question is this: having to clear your history/cache after making changes to the site is fine for me while working on it. But what happens to guests who view the site? Will they need to clear their history/cache every time I make an update?

If so, how do I stop this happening?

Our servers enforce quite strong caching of static files by default. The benefits of caching is that it will make your site appear faster to your visitors and reduces bandwidth on their end, while also reducing server load for your hosting account, meaning your site will be able to handle more visitors. The downside is that it will take some time for changes to files to be visible for everyone. But since most websites are viewed far more often that they are edited, this is an acceptable trade-off.

If you don’t want to wait, there are a few ways to go about it.

The first is to add some kind of version identifier to your files. For example, the forum includes a CSS file like this: https://forum.infinityfree.com/stylesheets/desktop_6_f2835f94463ce244a3e4cdeefeadb3824a26c840.css The sequence of random characters is generated along with the file itself, and if the file contents are changes, the random characters are changed too. So existing visitors will see the cache, while we can quickly deploy changes and make them visible to everyone. This is the best way to work around this, but can be quite hard to implement, depending on how your site works.

Alternatively, you can use .htaccess rules to disable cache entirely. But know that this WILL slow down your site and WILL increase your account’s resource usage. So please think twice before sacrificing the benefits of caching in favor of fast updates.

3 Likes

Thanks very much for this Admin, it’s really helpful!

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