- Table of Contents
- Related Documents
-
Title | Size | Download |
---|---|---|
05-Web cache policy configuration | 90.80 KB |
Configuring a Web cache policy
Restrictions: Hardware compatibility with Web cache policy
Restrictions and guidelines: Web cache policy configuration
Web cache policy tasks at a glance
Setting the aging time of cached files
Setting the maximum size of cached files
Configuring a Web cache policy
About Web cache policies
A Web cache policy allows you to cache frequently accessed webpages locally in files. If a user accesses the same URI before the cached file expires, the device responds with the file instead of sending the request to the server. By using a Web cache policy, you can alleviate the pressure on the server, reduce the transmission costs, and reduce the response time for users.
Other functional modules (for example, an LB virtual server) can use a Web cache policy to cache frequently accessed webpages.
Figure 1 Web caching process
A Web cache policy works as follows:
1. When the device receives an HTTP GET request from the host, it obtains the URI and searches for the URI in cached files.
¡ If a match is found, the device constructs a response and returns it to the host.
¡ If no match is found, the device proceeds to the next step.
2. The device reconstructs an HTTP GET request and sends it to the server.
3. After receiving the response from the server, the device checks whether the URI of the HTTP GET request can be cached.
¡ If yes, the device caches the response into a file, reconstructs a response, and sends it to the host.
¡ If not, the device reconstructs a response and sends it to the host.
Restrictions: Hardware compatibility with Web cache policy
Series |
Models |
Web cache policy compatibility |
M9000 series |
M9006, M9010, M9014, M9016-V |
No |
M9000-S series |
M9008-S, M9008-S-V |
Yes |
M9000-AK series |
M9000-AK001 |
Yes |
M9000-AI-E series |
M9000-AI-E4 |
Yes |
M9000-AI-E8, M9000-AI-E16 |
Yes |
|
M9000-X series |
M9000-X06, M9000-X06-B, M9000-X06-B-G, M9000-X06-G, M9000-X10 |
Yes |
M9000-AI-X series |
M9000-AI-X06, M9000-AI-X10 |
Yes |
M9000-CN series |
M9000-CN04 |
Yes |
Restrictions and guidelines: Web cache policy configuration
A Web cache policy supports data caching only for HTTP.
Web cache policy tasks at a glance
To configure a Web cache policy, perform the following tasks:
· (Optional.) Configure cache parameters
¡ Setting the aging time of cached files
¡ Setting the maximum size of cached files
¡ Setting the maximum size of a single cached file
Creating a Web cache policy
1. Enter system view.
system-view
2. Create a Web cache policy and enter Web cache policy view.
cache-policy cache-policy-name [ type http ]
The type http keywords are optional when you create a Web cache policy. If you specify them, you must also specify them when entering the view of an existing Web cache policy.
Creating a URI match rule
About this task
The device checks whether the URI of an HTTP request matches the URI specified in a match rule. If yes, the device caches the response of the request. If no match rule is configured, the device does not cache any responses.
Procedure
1. Enter system view.
system-view
2. Enter Web cache policy view.
cache-policy cache-policy-name [ type http ]
3. Create a URI match rule.
match [ match-id ] uri uri
Setting the aging time of cached files
About this task
A cached file is deleted if the corresponding URI is not requested when the aging time expires.
Restrictions and guidelines
A cached file is automatically deleted when its aging timer expires.
The aging timer of a cached file is not restarted when the device receives the same HTTP requests as the first HTTP request that triggers the generation of the file.
If you modify the aging time, the new setting takes effect only on newly generated files and does not affect existing files.
Procedure
1. Enter system view.
system-view
2. Enter Web cache policy view.
cache-policy cache-policy-name [ type http ]
3. Set the aging time of cached files.
aging-time time-value
The default setting is 60 minutes.
Setting the maximum size of cached files
About this task
When the total size of cached files reaches the configured maximum size, the device deletes the oldest cache files to save the new cache file.
Procedure
1. Enter system view.
system-view
2. Enter Web cache policy view.
cache-policy cache-policy-name [ type http ]
3. Set the maximum size of cached files.
size size-value
The default setting is 64 MB.
Setting the maximum size of a single cached file
About this task
A file exceeding the maximum size is not cached.
Procedure
1. Enter system view.
system-view
2. Enter Web cache policy view.
cache-policy cache-policy-name [ type http ]
3. Set the maximum size of a single cached file.
file-max-size file-size
The default setting is 2048 KB.
Display and maintenance commands for Web cache policies
Execute display commands in any view and reset commands in user view:
Task |
Command |
Display Web cache policy information. |
In standalone mode: display cache-policy [ name cache-policy-name ] [ slot slot-number cpu cpu-number ] In IRF mode: display cache-policy [ name cache-policy-name ] [ chassis chassis-number slot slot-number cpu cpu-number ] |
Display statistics for Web cache policies. |
display cache-policy statistics [ name cache-policy-name ] |
Clear cached files for Web cache policies. |
reset cache-policy [ cache-policy-name ] |
Clear statistics for Web cache policies. |
reset cache-policy statistics [ cache-policy-name ] |