Apache uses Expires_module to let the browser cache static files

Source: Internet
Author: User
Tags browser cache

Let the browser cache css, JS, pictures, static files and so on is very important things, so as to reduce the pressure on the server, the provincial browser often go to the service side to download these static files. Let's look at the configuration method below.
1. Open the Apache extension mod_expires.so and include the following line of code in the Apache configuration file.
LoadModule Expires_module modules/mod_expires.so
2. Configure the cache to include the following snippet in the Apache configuration file
<ifmodule expires_module>

#打开缓存
Expiresactive on
#css文件缓存7200000/3600/24=83 Days
Expiresbytype Text/css A7200000
#js文件缓存7200000/3600/24=83 Days
Expiresbytype Application/x-javascript A7200000
Expiresbytype Application/javascript A7200000
#html文件缓存7200000/3600/24=83 Days
Expiresbytype text/html A7200000
#图片文件缓存7200000/3600/24=83 Days
Expiresbytype Image/jpeg A7200000
Expiresbytype Image/gif A7200000
Expiresbytype Image/png A7200000
Expiresbytype Image/x-icon A7200000
</IfModule>
3. Testing
Access to files with pictures, css,js,html
Http://localhost:8080/test/test.html
With Firebug you can see that the response header information contains
Expires Tue, 13 Sep 2011 15:41:09GMT
Cache-control max-age=7200000

How to put not configure the cache, the above header information is not, haha, try it.

Apache uses Expires_module to let the browser cache static files

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.