Setting webpage images, css/js files, html static webpages, and even dynamic webpages to set cache time is not only to save server overhead, in more cases, users can feel "faster network speed". It is necessary to properly set the cache, especially images, css, js, txt, static html files, and other infrequently changed files.
Add the following code to the. htaccess file to set the webpage cache time. If this function is temporarily disabled during development and debugging.
The code is as follows: |
Copy code |
<FilesMatch ". (flv | gif | jpg | jpeg | png | ico | swf | css | txt | pdf) $"> Header set Cache-Control "max-age = 36000" </FilesMatch> |
This code is set to cache for 10 hours and can be modified as needed.
Note: Before making any changes, back up the website Data Domain. htaccess file.
Save the edited file. The value of the "max-age" parameter in the code is 36000 (seconds), so the image cache and Flash content are cached in the browser for 10 hours.