Take notes, go straight to work.
When you enter a URL directly in the browser, or click a link, then the browser cache will work, if the cache does not expire, then the browser will read from the local resources, do not initiate an HTTP request, if the cache expires, then the browser will initiate a new browser request. Byctrl+F5
, the browser empties the local cache and requests the resources again.
Expires
Is the http/1.0 's cache header,Cache-Control: max-age
Is http/1.1 is the header used for HTTP caching.
expires specifies the absolute time for resource expiration, GMT format, and cache-control:max-age specifies the relative time, in seconds, for resource expiration.
On browsers that support http/1.1, if you send two headers, the Cache-control:max-age will overwrite the expires;
On a browser that supports http/1.0, even if two headers are sent, only expires will work, so in order to be compatible with the old browser, you should send these two headers at the same time.
Setting the HTTP cache requires the installation of Expires_module, which sends expires and Cache-control:max-age two HTTP headers. The configuration is as follows:
<ifmodule expires_module> expiresactive on Expiresbytype application/x-javascript "Access Plus" Ex Piresbytype text/css "Access Plus" Expiresbytype image/gif "Access plus days" Expiresbytype image/jpeg "Access Plus" Expiresbytype image/png "Access plus days" </IfModule>
Two ways of writing
expiresbytype image/gif A2592000
# html
expiresbytype text/html M604800
ExpiresByType application/x-javascript "access plus 30 days"
represents the JS resource settingExpires
and theCache-Control: max-age
Head, whichExpires
The value is based on the time that the client accesses the resource 30 days after the baseline ,Cache-Control: max-age
The value is 3600x24x30 seconds.
There is a difference between the two ways, in front of the use of squid cache when
Modification time If short is easy to expire, squid will always request back-end Apache after expiration
Like what
The Diary of Squid
[27/sep/2015:10:51:12 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:10:57:00 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:10:58:03 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:00:34 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:00:52 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:01:13 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:04:13 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:06:29 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:06:39 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:07:09 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:08:27 tcp_refresh_unmodified:roundrobin_parent
[27/sep/2015:11:12:34 tcp_refresh_unmodified:roundrobin_parent
After modification
[27/sep/2015:11:14:53 Tcp_ims_hit:hier_none
[27/sep/2015:11:16:47 Tcp_ims_hit:hier_none
[27/sep/2015:11:19:44 Tcp_ims_hit:hier_none
[27/sep/2015:11:24:48 Tcp_ims_hit:hier_none
[27/sep/2015:11:26:09 Tcp_ims_hit:hier_none
[27/sep/2015:11:27:36 Tcp_ims_hit:hier_none
Back-end Apache has almost no logs, previously 304
This article is from the "drizzle" blog, please be sure to keep this source http://evildexy.blog.51cto.com/8607019/1698558
Apache Module Mod_expires