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.
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:
-
Users send requests to your resource.
-
Protection filters the requests and passes legitimate ones to your origin server.
-
The origin server sends responses.
-
Protection sends the responses to users.
At the same time, it checks whether any returned file has a
Cache-Controlheader with the required directives. If it does, protection caches the file. -
Users send new requests to your resource.
-
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
-
Submit a request to connect caching on the Strictera Application protection page or contact us at sales@strictera.com.
-
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-Controlheader that contains the required directives. -
We configure the
X-Verdict-Cache-Statusservice header in all responses that protection sends to users. This header lets you monitor caching.
-
-
Configure the
Cache-Controlheader on your side for the files you want to cache. Specify the required directives in this header.
|
|
| Directive | Meaning | Effect of the directive | ||
|---|---|---|---|---|
|
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. |
||
|
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. |
||
|
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.
|
||
|
The file must not be stored in any cache. |
Neither protection nor the user’s browser stores the file in the cache. |
||
|
The file storage period in any cache. For example, |
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 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.
|
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
-
Open the resource page in a browser.
-
Open
DevTools. -
Go to the
Networktab and clearDisable cache. -
Refresh the page.
-
Open the file request and find
X-Verdict-Cache-Statusin 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 If a repeated request still shows |