Apache opens Gzip and Expires to improve page load speed

  
                  

Find the following two lines in the Apache configuration file, remove the comment #, and restart.

LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so

Create a new .htaccess in your website directory, add the following content:

< ;IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType application /x-javascript A604800
ExpiresByType text/css A604800
</IfModule>

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css Image/gif image/jpeg image/png application/x-javascript
</IfModule>

Explain it. ExpiresByType is the MIME type to set the cache time of a specific file, A means access, and the number after A indicates the cache time after access. AddOutputFilterByType means to compress files according to the following MIME types. Here, gss compression is performed on css, html, gif, jpeg, png, JavaScript, etc. For more options, please refer to the apache manual.

Close ETag. The problem with Etag is that it is generated based on unique properties that identify the server on which the website is located. When the browser gets the page content from one server and then authenticates to another server, the ETag will not match. This is very common for websites that use server groups and handle requests. Write the following line in the configuration file:

FileETag none

If it is multi-server load balancing, you can set it to FileETag MTime Size, apache defaults to FileETag INode MTime Size, remove INode .

With the above settings, you can turn on compression and slow down.

Copyright © Windows knowledge All Rights Reserved