Apache. htaccess file Cache Picture Configuration method

Source: Internet
Author: User
Tags browser cache

The browser can simply read the cache control header for the. htaccess file, and the cache header will require the browser to keep the picture or any other media for 2 weeks (or more) so that the browser can call the picture at any time until the picture expires. After two weeks, the browser again caches expired pictures. In the event that the browser cache is emptied, the browser reloads the picture or other media from the cache.

1, open the. htaccess file of the root directory where the Web site resides, if not, create a new one.

2, enter the following code

The code is as follows Copy 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>

Description: The above code, is the browser cache format flv,gif,jpg,jpeg,png,ico,swf format file one 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 OK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.