How to speed up your website, it should be a concern for webmasters and bloggers. The speed at which a site is opened is related to many aspects, such as server performance, network speed, and web design of the site.
In the article "Best Practices for Speeding Up Your Web Site" on the Yahoo! Developer Network, we've introduced 34 suggestions for speeding up your site. Three of them are related to the optimization of the Web server. This article is specifically for these three suggestions to set up Apache to achieve the purpose of website acceleration.
Setting the expiration time for files
The purpose of this is to control the browser to cache files we don't modify often, such as images, css, js, etc., so that when the viewer opens another web page At the time of the reduction of the download of the file, the purpose of speeding up the website. To enable Apache to increase the file validity period, the browser cache can be implemented in two ways:
The first one: use the mod_headers module to increase the validity period of the file
Load the mod_headers module and add it to the configuration file. :
LoadModule headers_module modules/mod_headers.so
Configure the mod_headers module, set the jpg jpeg gif png ico js css swf flv and other files Expires: (Expires head can only be a fixed time, the image is said It seems that the expiration time of the product. The purpose of this is to be compatible with browsers that do not support Cache-Control. If Cache-Control is set and the browser supports Cache-Control, the Cache-Control setting is preferred. Support Cache-Control file header)
<FilesMatch "\\.(jpg|
Jpeg|
Gif|
Png|
Ico|
Js|
Css|
Swf|
Flv)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>
Configure the mod_headers module, set jpg jpeg gif png ico js css swf flv Cache-Control of the file: (The Cache-Control control is more flexible. It sets a valid time, which is like the shelf life of the product. The following 604800 units are seconds, which is the effective time for setting the file to 1 week) Br>
<FilesMatch "\\.(jpg|
Jpeg|
Gif|
Png|
Ico|
Swf|
Flv|
Js|
Css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
Second: Use the mod_expires module to add Expires
to the file. The mod_expires module, added in the configuration file:
LoadModule expires_module modules/mod_expires.so
Configure the mod_expires module:
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 weeks"
ExpiresByType text/css access plus 3 days
ExpiresByType image/gif "access plus 1 month "
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/plain "access plus 1 weeks"
ExpiresByType application/x-shockwave- Flash "access plus 1 month"
ExpiresByType video/x-flv "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/html "access plus 1 weeks"
Enable Gzip compression
To enable Apache to implement Gzip compression Open the mod_deflate module and the mod_headers module. The mod_headers module has been enabled. You can open the mod_deflate module here. Open the Apache configuration file and add:
LoadModule deflate_module modules/mod_deflate.so
Configure the mod_deflate module. Let it compress html xml css php js and other files:
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-httpd- Php application/x-javascript
AddOutputFilter DEFLATE html xml css php js
</ifmodule>
turn off ETags
Even if Expires or Cache-Control is set, sometimes browsers will often access resources when accessing resources Because the ETag exists and re-download the entire resource, it is easy to close them:
FileETag None
I believe that after setting the above 3 items, your site browsing speed will increase a lot if you can't feel it. For speed improvements, install Firefox's YSlow plugin to check if your settings are successful.
in the windows domain is in the domain of the windows 2003 active directory architecture. When the c
IIS 7.0, released with Windows Server 2008, is much more powerful than its predece
Now Windows 2000 system technology is more and more mature, the corresponding Server Pack has also b
In the previous section we introduced how to install Windows 2000 Se
Use memory configuration options to optimize server performance
IIS7 server can't load CSS style file how to solve
Skills delivery: three moves to improve the security of the FTP server
10 minutes analysis web server
Tips: How to build a nine-story server rack?
PHP Hash conflict leads to 100% complete solution for CPU
How to check and troubleshoot network problems through DNS technology?
Solve Nginx: [error] open() "/usr/local/Nginx/logs/Nginx.pid
When setting Windows 2003 to shut down or restart, the prompt box
What is the difference between the IMAP protocol and the POP protocol?
How does Win7 merge disks? Method of merging disks
The management server ensures that the actual management experience of security is shared.
How can I handle Win10 OneDrive files? What if OneDrive is not syncing?
How to uninstall IE browser in Win10 system? Win10 system uninstall IE browser tutorial
Win8 built-in mail application add account setting tutorial
Win7 32-bit Ultimate Quick Set Timed Shutdown Method
How to connect a Linux computer to the Internet with a cdma 1x phone
Windows 8 platform will be fully compatible with Windows Phone application
Windows8 preview version of Chinese (with Chinese language pack) (2)