Static content caching

What this service is, how it benefits your resource, and how to connect it.

Caching is available on request and only with the Proxy integration option.

What caching is

Caching is a mechanism that lets protection store copies of your files and then send them to users without requesting them from the origin server.

Which files you can cache

Any files. Usually, you cache static content: files that change rarely and are sent to all users in the same form. For example, icons, CSS styles, JavaScript files, images, or fonts.

How caching benefits your resource

Caching reduces the load on your origin server. Protection processes some requests itself, so your server receives fewer similar requests and works more reliably under high traffic.

Caching speeds up resource loading for users. If a file is already in the cache, protection sends it without requesting it from the origin server. The request path is shorter, and the response arrives faster.

Processing requests with and without caching

How caching works

Configure your side: add the Cache-Control header to the files you want to cache. Specify the required caching directives in this header. Then the process works as follows:

  1. Users send requests to your resource.

  2. Protection filters the requests and passes legitimate ones to your origin server.

  3. The origin server sends responses.

  4. Protection sends the responses to users.

    At the same time, it checks whether any returned file has a Cache-Control header with the required directives. If it does, protection caches the file.

  5. Users send new requests to your resource.

  6. Protection blocks illegitimate requests. It processes legitimate requests as follows:

    • If the requested file is in the cache, it sends the file from the cache.

    • If the requested file is not in the cache, it passes the request to your origin server.

When a file’s storage period expires, protection removes it from the cache. When the file is requested again, protection retrieves it from the origin server, stores a new copy in the cache, and sends it to the user.

How to connect caching

  1. Submit a request to connect caching on the Strictera Application protection page or contact us at sales@strictera.com.

  2. On our side, we enable caching:

    • We prepare a cache zone for your resource: 100 MB of dedicated space on our servers.

    • We configure caching so that the cache zone stores your files with a Cache-Control header that contains the required directives.

    • We configure the X-Verdict-Cache-Status service header in all responses that protection sends to users. This header lets you monitor caching.

  3. Configure the Cache-Control header on your side for the files you want to cache. Specify the required directives in this header.

Cache-Control is a general HTTP header that controls caching. It defines how your resource files are stored in a public cache, such as storage in systems between the user and your server, including the protection system, and in a private cache, which is local storage in the user’s browser.

Directive Meaning Effect of the directive

public

The file can be stored in both public and private caches.

Protection stores a copy of the file in the cache and sends it to users.

When the user’s browser receives the file, it also stores it in its local cache.

private

The file can be stored only in a private cache.

Protection does not store the file in its cache and requests it from the origin server every time.

When the user’s browser receives the file, it stores it in its local cache.

no-cache

Before using a cached copy, the origin server must check whether the file has changed.

Protection does not store the file in its cache and requests it from the origin server every time.

When the user’s browser receives the file, it stores it in its local cache. However, each time before using the local copy, the browser checks whether it is current.

How does the check work?

The browser:

  1. Sends a validation request.

  2. Receives a response from the server.

  3. Uses the copy if it is current. Otherwise, it requests a new file version from the server and stores it in the cache.

The server determines the validation method using validators included in the initial response. For example, the server can specify a unique resource-version identifier with ETag:

HTTP/1.1 200 OK
Cache-Control: no-cache
ETag: "version-42"

Before using the cached file copy, the browser checks ETag:

GET /page.html HTTP/1.1
If-None-Match: "version-42"

If the value has not changed, the browser can use the file. If it has changed, the browser requests the file again.

no-store

The file must not be stored in any cache.

Neither protection nor the user’s browser stores the file in the cache.

max-age=<seconds>

The file storage period in any cache. For example, max-age=3600 lets the cache store the file for one hour.

If a file copy is stored in a cache, either by protection or the user’s browser, it is removed after the specified time.

The maximum storage period for a copy on our side is 24 hours. If max-age specifies a longer value, protection still refreshes the copy after 24 hours.

s-maxage=<seconds>

The file storage period in a public cache. The user’s browser ignores this directive.

If a copy of the file is stored in the protection cache, it is removed after the specified time.

If you specify both max-age and s-maxage, protection uses s-maxage.

Cache-Control configuration examples

Example 1. Enable caching for a file

Header example: Cache-Control: public, max-age=3600.

This header allows the file to be stored in a cache for one hour.

Protection stores a copy of the file and sends it to users for one hour without requesting it from the origin server. It then removes the copy. When a new request for this file arrives, protection retrieves it from the origin server again, stores a copy in the cache, and sends it to users for one hour.

The user’s browser also stores this file in its cache for one hour.

Example 2. Set a separate storage period in a public cache

Header example: Cache-Control: public, max-age=3600, s-maxage=86400.

Both protection and the user’s browser store this file in their caches. However, their storage periods differ: one hour for the browser and 24 hours for protection.

Example 3. Disable caching for a file

Header example: Cache-Control: no-store.

This header prohibits storing the file in any cache. Use it for files that should not be cached.

How to check caching

  1. Open the resource page in a browser.

  2. Open DevTools.

  3. Go to the Network tab and clear Disable cache.

  4. Refresh the page.

  5. Open the file request and find X-Verdict-Cache-Status in the response headers. The header can have the following values:

    • HIT—the file was sent from the cache, so caching worked.

    • MISS—the file was not in the cache, so protection requested it from the origin server.

If a file can be cached and Cache-Control is configured correctly, the first request for the file shows MISS, and a repeated request shows HIT.

If a repeated request still shows MISS, check the Cache-Control header on your side. Make sure that public caching is allowed for the file and a storage period is set.