Press website updates without affecting the user

I am working on my first site right now, and when I update the file (uploading the latest version to the server), such as a stylesheet or file .php, and I try to load the page halfway, when it is loaded / modified, I get a blank screen or broken CSS. Sometimes the cache needs to be cleared to load the stylesheet correctly.

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

+4
source share
4 answers

One way to do this is a "cache failure." Each time you make changes to your file .cssor .js, 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 this after the file name:

style.css?v=1.0 // Release 1.0
style.css?v=1.1 // Release 1.1
style.css?v=2.0 // Release 2.0
+7
source

Regarding updates to the .php file, users should simply receive new responses from the updated files. As for CSS, I would suggest trying JavaScript through jQuery.

In any case, it’s good practice not to work with the live version of the website, but in the “sandbox” of a copy stored on your local computer or other folder on the server, and after you reach the desired functions, upload files at night or when your site has minimal traffic.

0
source

. , , , , , . , , :

  • , , , - . WAMP, MAMP, LAMP
  • . , .
  • .git
  • FTP. .
  • SSH . , , .

Workflow

- :

  • .git
  • , -
  • develop.
  • (/)
  • , , git merge develop --no-ff -m "message"
  • -, // -.
  • - , :
    • (.. ).
    • , - .
  • "", , .
0

, , ,

<script src="../assets/js/header.js?rndstr=<?php echo getCurrentTimeStamp();?>"></script>


function getCurrentTimeStamp(){
    return date('Y-m-d G:i:s');
}
0

Source: https://habr.com/ru/post/1606277/


All Articles