1.cache-control attributes:
If there is a script file can be determined for a long time will not change, and that through the browser can cache up this script, do not always request to the server. This will not only save bandwidth and improve performance.
At this time, just you need to set the file returned HTTP Cache-Control header is set to:Cache-Control: max-age=31536000(以秒计量)
2、expires
Negotiation cache validation steps:
-
Browser: Hey, I need jquery.min.js this document, if it is the last-modified: Tue, modified after 26 Nov 2019 13:25:13 GMT, please send me.
-
Modified server which checks the file)
-
Server: Hey, this document has not been modified after that time, you already have the latest version.
-
Browser: Great, I'll be displayed to the user.