Home > Article > Backend Development > Example of how to disable caching of js files
Disable js file caching, as follows: 1. Add: where the JS file is referenced:
similar to this form: js/YearReportLuRu.js?20100408154456, so that the browser will think that the js files referenced are different each time. Of course, YearReportLuRu.js does not process the subsequent dynamic numbers. 2. Just add: to the file header of the client page: Server side:
This method has been used in the program, but some users still have caching problems, and I personally feel that it has not been finally solved. Other methods: The server needs to be set to allow caching, so that the client will cache some static files (such as js, css, pictures) according to the client's settings. In IIS, you can set "Enable content expiration" in the "HTTP header" of the site properties to control the client cache time. (As shown below) In this way, the HTTP header returned by HTTP is 304. Enabling caching can greatly improve the user experience. It is also recommended to enable http compression to optimize the website. As shown below: This method is set on the WEB publishing server. Summary: Static files can be achieved with IIS or other WEB SERVERs. Caching the client is a mechanism problem of IE or other clients. Many users still have trouble clearing the client's cache. They can use programs to control cache problems. |