Fortinet Document Library

Version:


Table of Contents

User Guide

Download PDF
Copy Link

Caching and Compression

To improve performance of your back-end network and servers by reducing their traffic and processing load, you can configure FortiWeb Cloud to cache and compress responses from your servers.

To configure Caching and Compression, you must have already enabled this module in Add Modules. See How to add or remove a module.

When enabling caching make sure you correctly configured the web server’s no-cache/no-store directives to avoid caching sensitive data.
  1. Configure these settings.
  2. Default Cache Timeout

    Type the time to live for each entry in the cache. Expired entries will be removed.

    A subsequent request for the URL will cause FortiWeb Cloud to forward the request to the server in order to cache the response again. Any additional requests will receive FortiWeb Cloud’s cached response until the URL’s cache timeout occurs.

    Allow HTTP Method

    Select whether to cache the response contents according to the HTTP method you use.

    • GET, HEAD (Recommended)
    • GET, HEAD, OPTIONS
    • GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

    Allow Return Code

    Select whether to cache the response contents according to the response code.

    • 200 (Recommended)
    • 200, 206
    • 200, 206, 301, 302

    Allow File Type

    Select whether to cache the response contents according to the content type.

    • Text
    • Picture
    • Media
    • Binary
    • Other

    Key Generation Factor

    Select the protocol variable that you want to use to generate the cache key.

    • Method, such as GET, POST, HEAD, etc.
    • Protocol, the string can be either “http://” or “https://”;
    • Host
    • URL
    • Arguments, for example in request http://host.com/test.php?a=1&b=2
      , the Arguments string is “a=1&b=2”.
    • CookiesOnce you have created a web cache rule, you can edit the rule to indicate cookies in HTTP requests and append them to the key string to generate the cache key.
  3. Click Create New to configure the URLs not to be cached.
  4. Configure these settings.

    HTTP Method

    Select the HTTP method in which the request URL is included.

    URL Expression

    Enter a regular expression, such as ^/*.php, matching the sub URLs to which the rule should apply. The pattern does not require a slash ( / ), but it must match sub URLs that begin with a slash, such as /index.cfm.

    For details, see Regular expression syntax.

    Bypass Arguments

    Enable this option and enter the argument name so that the request matches the bypass URL only when the request brings the specific arguments.

    Bypass Cookies

    Enable this option and enter the cookie name so that the request matches the bypass URL only when the request brings the specific cookies.

  5. Click OK. You can continue creating multiple Bypass Sub URL lists.
  6. Enable Compression to completely offload compression to FortiWeb Cloud to save resources on your web servers.
  7. Select the content types that you want to compress. Click Change, select the content type, and then click the right arrow (->) to move them to the Allow Content Types list.
  8. Click SAVE.

You can click the Clear Cache button at the top right corner of the page to clear the responses cached on FortiWeb Cloud.

What can be cached?

Caching generally works best with data that doesn't change. Things like static web pages, images, movies, and music all typically work well.

When content changes often, caching provides overhead by consuming RAM without its usual benefit of reduced latency. Some HTTP headers and other factors indicate dynamic content which FortiWeb Cloud will not cache.

FortiWeb Cloud will not cache responses if the request:

  • Method is not GET (e.g. responses to POST are not cached)
  • Has fields such as Cache-Control: max-age=0/no-cache/no-store/; Pragma:no-cache
  • Contains URL with query string
  • Contains body
  • Contains the header:
    • Authorization
    • Proxy-Authorization
    • If-Modified-Since
    • If-Unmodified-Since
    • If-Match
    • If-None-Match

FortiWeb Cloud will not cache if the response:

  • Whose status code is not 200
  • Has a Vary: field
  • Forbids caching (e.g. Cache-Control: no-cache/no-store/private)
  • Has no Content-Length: field (e.g. Connection:close and Transfer-Encoding: chunked)
  • Has no cache expiry tag (e.g. Last-Modified/Etag and Cache-Control/Expires)
  • Contains the header:
    • WWW-Authenticate
    • Proxy-Authenticate
    • Set-Cookie
    • Set-Cookie2

 

Caching and Compression

To improve performance of your back-end network and servers by reducing their traffic and processing load, you can configure FortiWeb Cloud to cache and compress responses from your servers.

To configure Caching and Compression, you must have already enabled this module in Add Modules. See How to add or remove a module.

When enabling caching make sure you correctly configured the web server’s no-cache/no-store directives to avoid caching sensitive data.
  1. Configure these settings.
  2. Default Cache Timeout

    Type the time to live for each entry in the cache. Expired entries will be removed.

    A subsequent request for the URL will cause FortiWeb Cloud to forward the request to the server in order to cache the response again. Any additional requests will receive FortiWeb Cloud’s cached response until the URL’s cache timeout occurs.

    Allow HTTP Method

    Select whether to cache the response contents according to the HTTP method you use.

    • GET, HEAD (Recommended)
    • GET, HEAD, OPTIONS
    • GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE

    Allow Return Code

    Select whether to cache the response contents according to the response code.

    • 200 (Recommended)
    • 200, 206
    • 200, 206, 301, 302

    Allow File Type

    Select whether to cache the response contents according to the content type.

    • Text
    • Picture
    • Media
    • Binary
    • Other

    Key Generation Factor

    Select the protocol variable that you want to use to generate the cache key.

    • Method, such as GET, POST, HEAD, etc.
    • Protocol, the string can be either “http://” or “https://”;
    • Host
    • URL
    • Arguments, for example in request http://host.com/test.php?a=1&b=2
      , the Arguments string is “a=1&b=2”.
    • CookiesOnce you have created a web cache rule, you can edit the rule to indicate cookies in HTTP requests and append them to the key string to generate the cache key.
  3. Click Create New to configure the URLs not to be cached.
  4. Configure these settings.

    HTTP Method

    Select the HTTP method in which the request URL is included.

    URL Expression

    Enter a regular expression, such as ^/*.php, matching the sub URLs to which the rule should apply. The pattern does not require a slash ( / ), but it must match sub URLs that begin with a slash, such as /index.cfm.

    For details, see Regular expression syntax.

    Bypass Arguments

    Enable this option and enter the argument name so that the request matches the bypass URL only when the request brings the specific arguments.

    Bypass Cookies

    Enable this option and enter the cookie name so that the request matches the bypass URL only when the request brings the specific cookies.

  5. Click OK. You can continue creating multiple Bypass Sub URL lists.
  6. Enable Compression to completely offload compression to FortiWeb Cloud to save resources on your web servers.
  7. Select the content types that you want to compress. Click Change, select the content type, and then click the right arrow (->) to move them to the Allow Content Types list.
  8. Click SAVE.

You can click the Clear Cache button at the top right corner of the page to clear the responses cached on FortiWeb Cloud.

What can be cached?

Caching generally works best with data that doesn't change. Things like static web pages, images, movies, and music all typically work well.

When content changes often, caching provides overhead by consuming RAM without its usual benefit of reduced latency. Some HTTP headers and other factors indicate dynamic content which FortiWeb Cloud will not cache.

FortiWeb Cloud will not cache responses if the request:

  • Method is not GET (e.g. responses to POST are not cached)
  • Has fields such as Cache-Control: max-age=0/no-cache/no-store/; Pragma:no-cache
  • Contains URL with query string
  • Contains body
  • Contains the header:
    • Authorization
    • Proxy-Authorization
    • If-Modified-Since
    • If-Unmodified-Since
    • If-Match
    • If-None-Match

FortiWeb Cloud will not cache if the response:

  • Whose status code is not 200
  • Has a Vary: field
  • Forbids caching (e.g. Cache-Control: no-cache/no-store/private)
  • Has no Content-Length: field (e.g. Connection:close and Transfer-Encoding: chunked)
  • Has no cache expiry tag (e.g. Last-Modified/Etag and Cache-Control/Expires)
  • Contains the header:
    • WWW-Authenticate
    • Proxy-Authenticate
    • Set-Cookie
    • Set-Cookie2