As an example, a value of 0 means that objects will not be cached, unless they have a separately-defined caching directive. Note that in any case, if an object has a caching directive, the caching directive always takes precedence over any lifetime setting defined here in Edge Services.
How to configure an Edge Services cache
The cache feature allows you to cache your origin’s content with Edge Services. This means that content can be served directly to users from Edge Services’ servers, instead of from your Object Storage bucket or Load Balancer origin, enhancing performance.
You can disable and enable caching at will, as well as control the lifetime of an object in the cache. You can also purge your entire cache, or specific objects within it. A log is displayed to help you track your purge events.
How to enable the cache
-
In the Scaleway console, navigate to the Edge Services dashboard for the Object Storage or Load Balancer pipeline on which you want to enable caching:
-
In the Cache panel, use the «Toogle Icon» icon to enable the cache.
The Lifetime configuration box displays. This enables you to define, in seconds, how long an object can be stored in the cache before it must be retrieved freshly from the origin (Object Storage bucket or Load Balancer).
Tip -
Leave the default value of 1 hour in place, or enter another value.
The cache is now enabled.
How to purge all objects from your cache
Purging objects clears all objects from your cache. Afterward, Edge Services will retrieve fresh copies from the origin (Object Storage bucket or Load Balancer) before it stores them again in the cache.
-
In the Scaleway console, navigate to the Edge Services dashboard for the Object Storage bucket or Load Balancer pipeline whose cache you want to purge:
-
In the Purge cache panel, click Purge all.
A screen displays, warning you that your cache will be emptied, and Edge Services will have to retrieve objects from your origin before re-caching them.
-
Click Purge cache to confirm.
How to purge specific objects from your cache
This allows you to specify the precise objects that you want to clear from the cache. Afterward, Edge Services will retrieve fresh copies from the origin (Object Storage bucket or Load Balancer) before it stores them again in the cache.
-
In the Scaleway console, navigate to the Edge Services dashboard for the Object Storage bucket or Load Balancer pipeline whose cache you want to purge:
-
In the Purge cache panel, click Purge by object.
A screen displays prompting you to enter the path of each object you want to purge from the cache.
-
Enter the path of each object you want to purge. You can purge a maximum of 5 objects at a time.
TipThe path for each object should be defined from the root and must start with a slash, e.g.
/videos/my-video.mp4
.You cannot purge entire directories by simply specifying the path to the directory, e.g.
/videos
. Purging objects must be done strictly object-by-object, so/videos/my-video1.mp4
,/videos/my-video2.mp4
,/videos/my-video3.mp4
etc. Watch this space for updates to this feature in the future.For example, if we imagine an Object Storage bucket containing one file at the root level called
object1.jpg
, and a subfolder at root level calledvideos
containing an item calledmy-video.mp4
, we would enter the object paths as follows:/object1.jpg
/videos/my-video.mp4
-
Click Purge objects from cache.
The specified objects are purged from your cache and you are returned to the Edge Services dashboard.
How to use Cache-Control
To avoid repeated purging, you can also set the Cache-Control
HTTP header directly on your files/objects. This allows you to define how long items should remain in the cache before being freshly retrieved from the origin. Edge Services will respect this header when determining where to fetch content.
For Object Storage bucket origins, the following example call to the S3 API updates the Cache-Control
header for all objects in the bucket, setting a maximum age of 60 seconds before they must be freshly retrieved.
./s3cmd --recursive modify --add-header="Cache-Control:max-age=60" s3://yourbucket/
How to disable your cache
-
In the Scaleway console, navigate to the Edge Services dashboard for the Object Storage bucket or Load Balancer pipeline whose cache you want to disable:
-
In the Cache panel, use the «Toogle Icon» icon to disable the cache.
A pop-up displays, asking you to confirm the action.
-
Click Disable cache.
Your cache is purged and disabled. Edge Services will now serve content by fetching it from your origin (Object Storage bucket or Load Balancer) directly. If you reenable your cache at a later point, you will begin with an empty cache.