Apache mod_expires caches static files

Source: Internet
Author: User

Advantages of using apache mod_expires to cache static files:

Using static file caching can improve server performance, with the following benefits:

1. Shorten service response time

2. Reduce server burden

3. reduce network bandwidth usage

 Program Correction Method

The name is also changed each time you change static content (css, js, etc.

Append the version number or Build number.

<Link href = "/html/std.css? V = 2.5.3.text "rel =" stylesheet "type =" text/css ">

<Link rel = "stylesheet" type = "text/css" href = "html/std.css? _V2017804120090827100441.css "/>

The CSS file on the server is still named std.css. You need to add the version number to the html page.

After the version number is added, the modified page is displayed every time you update css or js without pressing CTRL + F5 to refresh the page.

 

 ApacheCorrection Method:

Add -- enable-expires in the Configure step when installing apache.

After installation, mod_expires.so will be displayed in the modules directory of the apache installation directory.

At the same time, it will be automatically added in Httpd. conf

LoadModule expires_module modules/mod_expires.so

 

 Httpd. confConfiguration

 

ExpiresActive on

# Cache for 3 days.

ExpiresBytype text/css "access plus 3 days

ExpiresByType application/x-javascript "access plus 3 days"

ExpiresByType image/jpeg "access plus 3 days"

Expiresbytype image/gif "access plus 3 days"

 

 

 

 

 

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.