Set static content cache time
39 problems-client cache time can be set for infrequently changed static resources to reduce requests
FAILED-(max-age or expires not Set)-http://pic.111cn.net/h470.gif
FAILED-(max-age or expires not Set)-yun_qi_img/51idc.gif
FAILED-(max-age or expires not Set)-yun_qi_img/zoneidc.gif
FAILED-(max-age or expires not Set)-http://www.111cn.net/
FAILED-(max-age or expires not Set)-http://pic.111cn.net/zgsj.gif
This feature has never been used by Baidu before.
Page Cache is controlled by "cache-control" in the HTTP message header. Common values include private, no-Cache, max-age, and must-revalidate, the default value is private. The function of browser review is divided into the following situations:
(1) open a new window
If the cache-control values are private, no-cache, and must-revalidate, the server will be accessed again when a new window is opened. If the max-age value is specified, the server will not be accessed again within the time range. For example:
Cache-control: max-age = 5
Indicates that the webpage will not go to the server again within 5 seconds after it is accessed.
(2) press enter in the address bar.
If the value is private or must-revalidate (not the same as on the Internet), the server will be accessed only when the first access is made and will not be accessed later. If the value is no-cache, it will be accessed every time. If the value is max-age, the access will not be repeated before expiration.
(3) back and press the button
If the values are private, must-revalidate, and max-age, no re-access will be performed. If the value is no-cache, the access will be repeated each time.
(4) press the refresh button
No matter what the value is, it will be accessed again
When the Cache-control value is "no-cache", accessing this page will not leave page backup in the temporary article folder on the Internet.
In addition, specifying the "Expires" value also affects the cache. For example, if you specify the Expires value as a time that has passed, if you repeatedly press enter in the address bar when accessing this network, the access will be repeated each time:
Expires: Fri, 31 Dec 1999 16:00:00 GMT
In ASP, the Expires and ExpiresAbsolute attributes of the Response object can be used to control the Expires value. The CacheControl attribute of the Response object can be used to control the Cache-control value. For example:
The code is as follows: |
Copy code |
Response. ExpiresAbsolute = #2000-1-1 # 'specifies the absolute Expiration Time, which is the local time of the server and is automatically converted to GMT. Response. Expires = 20' specifies the relative expiration time, in minutes, which indicates how many minutes have expired since the current time. Response. CacheControl = "no-cache" The Expires value can be viewed by viewing the properties of the temporary file in the temporary folder on the Internet. |
Okay, I found a solution on the apache server.
You can also use the mod_headers module to modify cache-control for apache cache settings.
Header set cache-control "max-age =" 3600 ".
Mod_expires instance:
The code is as follows: |
Copy code |
<Directory/opt> ExpiresActive On ExpiresDefault "accesss plus 3600 seconds" if it is 1 second, it is followed by seconds ExpiresByType application/octet-stream "accesss plus 1 months" this is cache for a special file type bin for 1 month <FilesMatch foreign data.swf $> set the Expire value for data.swf in the object directory. ExpiresActive On ExpiresDefault "accesss plus 60 seconds" </FilesMatch> </Directory> |
Mod_headers instance
The code is as follows: |
Copy code |
<Directory/opt> Header set cache-control "max-age = 3600" <FilesMatch between data.swf $> Header set cache-control "max-age = 60" </FilesMatch> </Directory> |