Mobile app version of vmapp.org
Login or Join
Speyer207

: What happens if CSS file falls out of cache but HTML file doesn't? I have a static HTML page for which I have set a cache-control max-age of 6 months, and it calls a style_v1.css file with

@Speyer207

Posted in: #Cache #CacheControl

I have a static HTML page for which I have set a cache-control max-age of 6 months, and it calls a style_v1.css file with a max-age of a year. What happens when I update the HTML file to call my redesigned style_v2.css?

I realise that users who have both files cached will see the old version, and users who have the CSS cached but not the HTML will download style_v2.css and everything will be fine. But is there a chance that the CSS file falls out of a user's cache, but the HTML file doesn't? In which case, what happens when the HTML page looks for style_v1.css and it isn't there anymore? Is the only solution to keep all previous versions of the CSS file on the server?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Speyer207

2 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

The situation you describe is very unlikely. Most browsers don't cache files for more than a few days before the space in cache is reclaimed. Browsers usually push items out of cache based on how recently they were used. Since the files are used together they will probably get pushed out of cache at the same time.

If you are worried about it, you can redirect your old CSS file to the new one. The old page may not look perfect with the new CSS, but it would be better than the user getting no styling.

10% popularity Vote Up Vote Down


 

@Dunderdale272

Don't overthink people's caches too much.

Your web server is the authority on what's up-to-date, just make sure that the css files referenced by your current html file are there and you'll be good to go.

If you no longer reference style_v1.css from any of your pages, then it is safe to delete it.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme