This article to introduce the PHP control page browser cache and enable the Gzip transfer page method, I hope this code will help you with this, and no server permissions friends can do this to achieve Server Gzip page transfer.
PHP Instance gzip Transfer page
| The code is as follows |
Copy Code |
Can be used for static resources and HTML pages, modification is also suitable for other languages Cache Expiration Time (Cache-control, http1.1), recommended $secs = 0; Seconds Header ("Cache-control:s-maxage= $secs, max-age= $secs, Must-revalidate, proxy-revalidate"); Cache expiration Time is 24 hours (Expires) $offset = 3600 * 24; $expire = "Expires:". Gmdate ("D, D M Y h:i:s", Time () + $offset). "GMT"; Header ($expire); Last-modified, Last modified time $gmt _mtime = gmdate (' d, D M Y h:i:s ', Time ()). ' GMT '; Header ("last-modified:".) $gmt _mtime); Enable gzip compression Ob_start (); ... your PHP code ... ... your PHP code ... ... your PHP code ... Header (' Content-length: '. Ob_get_length ()); Ob_end_flush (); |
If you have server privileges refer to Apache open gzip transfer
One, find your httpd.conf file and open to find the following
LoadModule Deflate_module modules/mod_deflate.so
Put the front of the # go, because the mod_deflate.so module is closed by default, okay.
Two, put the present surface code to your httpd.conf file at the end of the good.
| The code is as follows |
Copy Code |
Setoutputfilter DEFLATE Deflatecompressionlevel 5 Addoutputfilterbytype DEFLATE text/html text/css image/gif image/jpeg image/png application/x-javascript |
Restart your Apache, KO.
IIS opens the Gzip page transfer
1. Open Internet Information Services (IIS) Manager, right-click Web Site-Properties, and select Services. Select "Compress application Files" and "Compress static files" in the "HTTP Compression" box, set "Temp directory" and "Maximum limit of temporary directory" as required;
2. In Internet Information Services (IIS) Manager, right-click on "Web Service Extensions"-"Add a new Web service extension ...", enter the extension "HTTP Compression" in the "new Web service Extension" box, and add "required files" For C:windowssystem32inetsrvgzip.dll, where the Windows system directory may differ depending on your installation, check "set extended status to allow";
3. Open the C:windowssystem32inetsrvmetabase.xml with a text editor (it is recommended to back up first),
Locate location = "/lm/w3svc/filters/compression/gzip is used to set gzip compression,
Locate location = "/lm/w3svc/filters/compression/deflate" to set deflate compression. The top two nodes are immediately next to each other. and set the same properties.
If you need to compress the dynamic file, set HcDoDynamicCompression to "TRUE",
and add in hcscriptfileextensions the dynamic file suffix name you want to compress, such as ASPX;
If you need to compress the static files, set HcDoStaticCompression and HcDoOnDemandCompression to "TRUE",
And in the hcfileextensions, you need to compress the static file suffix name, such as XML, CSS, etc.;
HcDynamicCompressionLevel and HcOnDemandCompLevel indicate the required compression rate, the value is 0-10, and the default is 0.
HcDynamicCompressionLevel attribute Description: HcDynamicCompressionLevel Metabase Property
HcOnDemandCompLevel attribute Description: HcOnDemandCompLevel Metabase Property
Note: These two property values are generally recommended to be set to 9, with the best price/performance ratio.
Attention
1. To stop IIS before editing MetaBase.xml, you can use the net stop IISAdmin
2. After the modification is complete, turn on the IISAdmin service and execute the IISRESET command
About the SEO test
Whether the compression of SEO has an impact, after testing, open can still be well included.
About the impact of SEO research articles, you can also refer to the following articles.
Specific efficiency issues will continue to be monitored for research
http://www.bkjia.com/PHPjc/632650.html www.bkjia.com true http://www.bkjia.com/PHPjc/632650.html techarticle this article to introduce to you the PHP control page browser cache and enable the Gzip transfer page method, I hope this code for you with this will help, while no server permissions of friends can ...