Server Load Balancing : Configuring caching rules
 
Configuring caching rules
The system cache can store HTTP content. The system can serve subsequent HTTP requests for that content without forwarding the requests to the backend servers, thereby reducing the load on the backend servers.
Figure 27 illustrates the caching feature. The following table explains the communication.
Table 12: Caching behavior
Before content is cached
After content has been cached
1. FortiADC receives the request from Client A and checks to see if it has a cached copy of the content.
2. If it does not, it forwards the request to a backend server.
3. The server sends content in response, and FortiADC caches the content.
4. FortiADC sends it to the client.
1. FortiADC receives the request from Client B and checks to see if it has a cached copy of the content.
2. It does, so it responds by sending the content to the client. The backend server is not contacted.
Figure 27:  Caching feature
In general, the RAM cache conforms with the cache requirements described in sections 13 and 14 in RFC 2616.
If caching is enabled for the profile that is applied to traffic processing, the system evaluates HTTP responses to determine whether or not to cache the content. HTTP responses with status codes 200, 203, 300, 301, 400 can be cached.
The following content is not cached:
A response that does not include the Content-Length header.
A response for a request that uses any method other than GET.
A response for a request of which URI is contained in URI Exclude List.
A response for a request that contains any of the following headers: If-Match, If-Unmodified-Since, Authorization, Proxy-Authorization.
A response that contains any of the following headers: Pragma, Vary, Set-Cookie, and Set-Cookie2.
A response that does not contain the following headers: Cache-Control, Expires.
A response with a Cache-Control header that has one of the following values: no-cache, no-store, private.
A response with a Cache-Control header that does not have any of the following values: public, max-age, s-maxage.
In addition, content is not cached if the user-configured RAM cache thresholds described below are exceeded, or if the content is contained in a response for a request to a URI in the user-specified URI Exclude List.
Before you begin:
You must have a good understanding of caching and knowledge about the size of content objects clients access on the backend servers.
You must have Read-Write permission for Load Balance settings.
Caching is not enabled by default. After you have configured caching, you can select it in the profile configuration. To enable caching, select the profile when you configure the virtual server.
To configure caching:
1. Go to Server Load Balance > Profile.
2. Click the Caching tab.
3. Click Add to display the configuration editor.
4. Complete the configuration as described in Table 13.
5. Save the configuration.
Table 13: Caching configuration
Settings
Guidelines
Name
Unique name. No spaces or special characters.
After you initially save the configuration, you cannot edit the name.
Maximum Object Size
The default is 1 MB. The valid range is 1 byte to 10 MB.
Maximum Cache Size
The default is 100 MB. The valid range is 1 byte to 500 MB.
Maximum Entries
The default is 10,000. The valid range is 1 to 262,144.
Maximum Age
The default is 43,200 seconds. The valid range is 60 to 86,400.
The backend real server response header also includes a maximum age value. The FortiADC system enforces whichever value is smaller.
URI Exclude List
Click Add and specify URIs to build the list. You can use regular expressions.