XAMPP enable cache (1)

Source: Internet
Author: User
Overview of Apache module mod_expires

This module controlsExpiresHeader content andCache-ControlHeadermax-ageCommand. The validity period (expiration date) can be set to the last modification time relative to the source file or the client access time.

These HTTP headers indicate the validity and durability of the document to the client. If there is a cache, the document can be read from the cache (except that it has expired) rather than from the server. Next, the client checks the cached copy to see if it expires or fails to determine whether updates must be obtained from the server.

To modifyCache-ControlHeadermax-age(See RFC 2616 section 14.9 ).HeaderCommand.

Alternate (alternating/rotating) interval (interval) syntax (syntax)

ExpiresDefaultAndExpiresByTypeCommands can also be defined in easy-to-understand syntax formats:

ExpiresDefault "<base> [plus] {<num> <type>}*"
ExpiresByType type/encoding "<base> [plus] {<num> <type>}*"

<Base> is one of the following:

  • access
  • now(Equivalent'access')
  • modification

plusThe keyword is optional. <Num> must be an integer [can beatoi()Accepted], <type> is one of the following:

  • years
  • months
  • weeks
  • days
  • hours
  • minutes
  • seconds

For example, the following three commands indicate that the default validity period of a document is one month:

ExpiresDefault "access plus 1 month"
ExpiresDefault "access plus 4 weeks"
ExpiresDefault "access plus 30 days"

The validity period can be further adjusted by adding the "<num> <type>" clause:

ExpiresByType text/html "access plus 1 month 15 days 2 hours"
ExpiresByType image/gif "modification plus 5 hours 3 minutes"

Note: If you use the settings based on The Last modified Date, the "expires:" header willNoAdded to content that is not from a disk file. This is because the "Last Modified Time" attribute does not exist in the content.

Expiresactive command
Description Enable or disable generate"Expires:"And"Cache-Control:"Header Function
Syntax ExpiresActive On|Off
Scope Server config, virtual host, directory,. htaccess
Overwrite Indexes
Status Extension (E)
Module Mod_expires

This command enables or disables the generation of documents within the scope of its functionExpiresAndCache-ControlHeader. If it is setOffNo document is generated for the scope of its function.ExpiresAndCache-ControlHeader (unless it is rewritten by a lower-level rule, such.htaccessFile ). If it is setOnAccordingExpiresByTypeAndExpiresDefaultThe standard of instruction definition is the generation of documents within the scope of its functionExpiresAndCache-ControlHeader.

Note that this command is not guaranteedExpiresOrCache-ControlHeaders are generated. If the defined standard is not standardized, the two headers will not be generated, and the effect is as if this command has never been set.

Expiresbytype command
Description Configured by the MIME typeExpiresHeader Value
Syntax ExpiresByType MIME-type <code>seconds
Scope Server config, virtual host, directory,. htaccess
Overwrite Indexes
Status Extension (E)
Module Mod_expires

This command defines a document for the specified MIME type (for exampletext/html) GeneratedExpiresHeader Value andCache-ControlHeadermax-ageCommand.SecondsThe parameter sets the number of seconds that are added to the benchmark time to construct the validity period.Cache-Control: max-ageIs calculated from the validity period minus the current request time and converted to seconds.

The reference time can be the last modification time of the source file or the time when the client accesses the source file.<code>. "M"Indicates the last modification time of the source file ,"A"Indicates the time when the client accesses the source file. Note that<code>AndsecondsThere is no space between them.

The differences between the two benchmarks are subtle. If"M", All copies of the document in the current cache will expire at the same time, which may be good for regularly updated URLs (such as weekly announcements located at the same location. If"A", The validity period of each client is different, which may be very good for those image files that are hardly updated, especially for a group of documents that reference the same image.

Example:

# Enable validity period Control
Expiresactive on
# GIF is valid for 1 month
Expiresbytype image/GIF a2592000
# The validity period of the HTML document is one week after the last modification time
Expiresbytype text/html m604800

Note that this command is only available in"ExpiresActive On. ItOnlyRewrite the specified mime-type documentExpiresDefaultThe validity period set by the command.

You can also use the alternate syntax described earlier to specify the validity period.

Expiresdefault command
Description Calculation Method of default Validity Period
Syntax ExpiresDefault <code>seconds
Scope Server config, virtual host, directory,. htaccess
Overwrite Indexes
Status Extension (E)
Module Mod_expires

This command sets the calculation method for the default Validity Period of all documents within the scope of its function. It can beExpiresByTypeThe command is rewritten based on the MIME type. For more information, seeExpiresByTypeDescription of the command and the alternate syntax.

XAMPP enable cache (1)

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.