Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push website updates without affecting the user

I'm working on my first website right now, and when I'm updating a file (uploading the newest version to the server), for example the stylesheet or a .php file, and I try to load the page halfway through it being uploaded/changed, I get a blank screen or broken CSS. Sometimes the cache has to be cleared for the correct stylesheet to load.

When pushing updates to users, how can this be prevented?

like image 985
frosty Avatar asked Mar 15 '23 20:03

frosty


1 Answers

One way to do this is with "cache busting". Everytime you make changes to your .css or .js file you rename the file.

style_v1.0.css // Release 1.0
style_v1.1.css // Release 1.1
style_v2.0.css // Release 2.0

Or do it after the filename:

style.css?v=1.0 // Release 1.0
style.css?v=1.1 // Release 1.1
style.css?v=2.0 // Release 2.0
like image 132
Daan Avatar answered Mar 24 '23 00:03

Daan