Set the cache duration (TTL) for browsers
Files are cached on your Sirv CDN and in your users' browsers, for the fastest possible loading speed.
This article explains the default cache settings and how to change them.
Sirv CDN automatically stays up to date. You don't need to manually purge the CDN after you upload new versions of files to Sirv. All cached versions of the old file are invalidated within 3 seconds across Sirv's CDN, meaning the old file will never be served again. However, it might still exist in a users browser cache, so consider adjusting the default browser cache duration or select 'Purge from cache' and the latest version will display for all visitors.
Browsers cache (save) files so help them load fast, rather than re-downloaded the same files again from the CDN.
Sirv sets an "expires header" of 7 days by default, meaning that file will live in the browser cache for the next 7 days. Known as the TTL (time to live), 7 days is a broadly suitable period for files that change relatively frequently. If your files change rarely, consider increasing the TTL as long as 1 year. If they change frequently, consider reducing it to 1 day or even less.
It's easy to set your browser cache duration to one of the following expiries:
- 1 hour
- 3 hours
- 12 hours
- 1 day
- 7 days
- 30 days
- 1 year
This global setting applies to all files in your Sirv account, specified in your Default profile. (It can be overridden with a profile, see below).
To change the default duration:
1. Go to your Default profile. Browsers cache images for the duration specified in thewhich is served with each file.
2. Click 'Delivery settings' in the top left.
3. Change the value then click Save:
To set a different cache expiry time for specific files, apply a profile to those files. Each profile can have its own cache expiry time.
A profile can be applied by appending its name in the URL, for example:
In the above example, the profile is named "long-expiry".
Files delivered from scripts.sirv.com and video.sirv.com have a TTL of 7 days.