HTTP Zones (also known as Cache Rules) use a simple wildcard format to altered behavior and caching of specific locations and file extensions. The wildcard character of * and | character can be used to supply multiple options for a rule. See the examples below for more information.

Examples:

Rule Description Matches
/abc/* Matches a static file directory or path component "/abc/", "/abc/1.html", "/abc.html"
*.css Matches an extension of css "/a/main.css", "/main.css"
/style/*.css Matches an extension of css within the directory of style "/style/main.css", "/style/2/main.css"
/abc.html Matches /abc.html exactly only "/abc.html"
*.css\|*.js Matches an extension of css or js "/a/main.css", "/jquery.js"
type:images Matches images. Valid types include: images, resources, documents and sound "image.png", "image.jpg"

Expressions are matched in order from top to bottom with the lookup stopping at the first found match. This means that the order of the rules is important. The first matching rule will be used.

Pre-defined Types

We supply a set of pre-existing cache categories that can be applied over many filetypes (using the type:<typename> syntax). These are as follows:

  • images: Matches .jpg, .jpeg, .gif, .ico, .png, .bmp, .pict, .tif, .tiff, .svg, .svgz
  • sound: Matches .midi, .mid, .pls, .mp3, .wav
  • documents: Matches .csv, .doc, .pdf, .ppt, .eps, .docx, .xlsx, .xls, .pptx, .ps
  • resources: Matches .css, .js, .swf, .ttf, .eot, .woff, .ejs, .class, .jar, .otf, .webp

Caching for images is enabled by default.

Have we missed your favorite filetype? You can define custom rules using the wildcard format.

Cache conditions

There three conditions that determine if a request is to be stored into the cache.

  1. If the file is over 10mb, it will not be cached.
  2. The headers are checked to ensure the content requested is cacheable
  3. There is no content adjusting mitigation event ocurring on this request

The cache is not for storing large files, each service is limited at 100mb. Data is expired on a Least Recently Used basis in addition to the Expiration time.

Cache Policies

The following cache policies are available:

  • Cache: Caching is enabled by this rule (default for cache rules)
  • Disabled: Caching is disabled by this rule (default for ports)
  • Force: Caching is enabled for nearly all requests (regardless of headers)
  • Fallback: Serving from cache is only enabled when the backend is offline

In Cache mode Cache-Controla and Expires headers are honored. Specifically:

  • Cache-Control: private skips storage into the cache
  • Cache-Control: no-store skips storage into the cache
  • Cache-Control: no-cache skips storage into the cache
  • Cache-Control: max-age=0 skips storage into the cache
  • Expires: <past-date> skips storage into the cache

Headers

The cache honors backend's Expires, Cache-Control: no-cache, and Cache-Control: max-age=XXX headers. We do not handle "Vary" headers when caching. In order to ensure private items are not served to all users unintentionally by the cache, the back-end can set "no-cache" or "max-age=0".

The following response headers flag a response as uncachable:

  • Set-Cookie
  • Cache-Control containing no-cache, no-store, private, or a max-age with a non-numeric or 0 value
  • Expires with a time in the past
  • X-Accel-Expires: 0

Redirection

It optionally possible to define a redirect for a matching HTTP Zone. In this situation any caching settings will not take effect.

Redirection URLs mat contain the following variables:

-$scheme - The requested scheme (e.g "http" or "https") - $host - The requested domain name - $uri - The path of the current request, including the leading slash - $request_uri - Urlencoded path and query string component of a request, including the leading slash

For example, it is possible to redirect all requests to the https version of your site with a rule such as the following: https://$host$uri

Additional Notes

  • HTTP Zones paths can contain spaces and other special characters.
  • Duplicate slashes in paths (e.g aa//bb) will be combined into a single slash (e.g aa/bb). HTTP Zones cant match duplicate forward slashes in url (like most browsers).