apache USES the.htaccess file cache image configuration method

  • 2020-05-07 20:50:07
  • OfStack

The browser can simply read the cache control header of the.htaccess file, and the cache header requires the browser to keep the image or any other media for 2 weeks (or longer) so that the browser can call the image at any time until the image expires. After two weeks, the browser reloads the expired images into the cache. The 10000 browser cache is cleared and the browser reloads images or other media from the cache.

1. Open the.htaccess file of the root directory where the website is located. If not, please create a new one.

2. Enter the following code


# Image and Flash content Caching for One Month
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>


Note: the above code, the browser cache is format flv gif, jpg, jpeg, png, ico, swf format file 1 months. If you want to change the cache time, modify the max-age value

3, if you need to cache other format files, please modify the format on OK


Related articles: