Configure an Edge Services cache
The cache feature lets Edge Services store and serve your backend content to users directly from its own servers, not from your backend, 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 available to help you track your purge events.
Before you start
To complete the following actions, you must have:
- A Scaleway account logged into the console (External link)
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An Edge Services pipeline
Enable the cache
-
In the Scaleway console (External link) side menu, go to Network > Edge Services. A list of your pipelines appears.
-
Click the name of the pipeline you want to enable cache for, then open the Settings tab.
-
In the Cache panel, click Enable cache. A configuration dialog box appears.
-
Configure the Lifetime of the cached objects to define how long they can be stored in the cache before they must be retrieved freshly from the pipeline backend.
-
Click Save to proceed.
The cache is now enabled.
Purge all objects from your cache
Purging objects clears all objects from your cache. Afterward, Edge Services will retrieve fresh copies from the backend before it stores them again in the cache.
-
In the Scaleway console (External link) side menu, go to Network > Edge Services. A list of your pipelines appears.
-
Click the name of the pipeline you want to enable cache for, then open the Settings tab.
-
In the Purge cache panel, click Purge all.
A dialog box opens, warning you that your cache will be emptied, and Edge Services will have to retrieve objects from your backend before re-caching them.
-
Click Purge cache to confirm.
All objects are purged from your cache.
Purge specific objects from your cache
You can specify the precise objects that you want to clear from the cache. Afterward, Edge Services will retrieve fresh copies from the backend before it stores them again in the cache.
-
In the Scaleway console (External link) side menu, go to Network > Edge Services. A list of your pipelines appears.
-
Click the name of the pipeline you want to enable cache for, then open the Settings tab.
-
In the Purge cache panel, click Purge by object.
A dialog box prompts 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, keeping in mind that:
- You should define the path for each object from the root and the path must start with a slash (e.g.,
/videos/my-video.mp4). - You cannot purge entire directories by specifying the path to the directory (e.g.,
/videos). Purging objects must be done object-by-object (/videos/my-video1.mp4,/videos/my-video2.mp4, etc.).
For example, if an Object Storage bucket contains a root-level file named
object1.jpgand a subfoldervideoscontainingmy-video.mp4, the paths would be/object1.jpgand/videos/my-video.mp4. - You should define the path for each object from the root and the path must start with a slash (e.g.,
-
Click Purge objects from cache.
The specified objects are purged from your cache.
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 backend. Edge Services will respect this header when determining where to fetch content.
For Object Storage bucket backends, the following S3 API call example updates the Cache-Control header of all objects in the bucket to a maximum age of 60 seconds. After this time, the cache must retrieve a fresh copy of each object.
./s3cmd --recursive modify --add-header="Cache-Control:max-age=60" s3://yourbucket/Disable your cache
-
In the Scaleway console (External link) side menu, go to Network > Edge Services. A list of your pipelines appears.
-
Click the name of the pipeline you want to enable cache for, then open the Settings tab.
-
In the Cache panel, click Disable cache.
A confirmation dialog box appears.
-
Click Disable cache.
Your cache is purged and disabled. Edge Services will now serve content by fetching it from your pipeline backend directly. If you re-enable your cache later, it will start empty.
Troubleshooting cache problems
See the troubleshooting documentation on resolving unexpected caching behavior with Edge Services.