Apache Module Mod_expires

Source: Internet
Author: User
Tags browser cache

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.
ExpiresIs the http/1.0 's cache header,Cache-Control: max-ageIs 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 settingExpiresand theCache-Control: max-ageHead, whichExpiresThe value is based on the time that the client accesses the resource 30 days after the baseline ,Cache-Control: max-ageThe 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.