0

I have a 'static' website (there is no content management system database).

I've just made changes to the .html files and .css file of the site.

I've renamed the .css file: version2.css because I thought that would help.

I've uploaded the changes to my server and checked the site. However, because of cache (I presume) the site doesn't look any different.

When I refresh I can see the changes to the content and style, but I can't see changes to images (where the name of the image has remained the same). I can only see the changes to images after clearing browser data.

So my question is how can I ensure returning visitors see the new site / changes? How long do browsers store history / cache for? From other posts it looks like browsers store around 50mb of info. If this is the case then for a lot of people their browsers could be emptying the cache every day, in which case it isn't a big problem for me?

Is there a solution that doesn't involve PHP or apache conf (both of which I know nothing about)?

Thank you (from a beginner)

user2991837
  • 626
  • 1
  • 8
  • 17

2 Answers2

1

You are sort of on the right track you can provide version numbers to existing files which will force browsers to reload the data.

<img src="/logo.jpg?version=1">
<link rel="stylesheet" type="text/css" href="/style.css?version=1">
Dylan
  • 2,161
  • 2
  • 27
  • 51
  • Is "style.css?version=1" better than "style-version1.css"? – user2991837 Jan 14 '20 at 14:00
  • Effectively it does the same thing but by doing ?version=1 you don't have to keep creating new file names and can just keep saving the file as logo.jpg in this example. – Dylan Jan 14 '20 at 14:02
  • So is ?version=1 an automated thing, or something I would have to manually add? – user2991837 Jan 14 '20 at 14:04
  • You would manually add it to your html file but just save your css file as style.css instead of both renaming the css file and changing the html – Dylan Jan 14 '20 at 14:09
  • so who or how do I change images and css so that the ?version="1" is added to all the file names? I'd hate to have to do that manually – user2991837 Jan 14 '20 at 14:11
0

I was successful by ensuring that I updated the name of the .js and .css files with a new tag (and change the index to properly direct to them), then being sure to delete the originals. I suspect that when a browser cannot find a file it will finally update the index, then load the correct file.

sheepdeets
  • 49
  • 4
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Heri Hehe Setiawan Aug 25 '23 at 14:23