IMPORTANT - Cloudimage is a SaaS for image optimisation and delivery over the internet. Cloudimage provide Image Caching and it is not a storage solution that will keep customer original files. If you are looking for a solution including a storage feature, we recommend your to explore our Digital Asset Management solution - Filerobot that also offers all Cloudimage functionalities as native.
The TOP-3 main reasons why it seems like the image files do not last in the CDN cache as long as stated in the s-maxage directive:
Reason 1 – In some rare cases when the origin URL(s) are time stamped or sealed with expiration period, at some point they become unavailable on the Origin server.
If some of the CDN servers around the globe request the image in this moment, Cloudimage would try to fetch it from the Origin server and will receive status code 404 (File Not Found).
Please note that the CDN caching is triggered upon a user request, it is not triggered when you set up the s-maxage value in the Cloudimage Admin panel. It means, that the first user request in some local CDN Point-of-Presence (PoP) may be requested weeks and months after the initial setup of your Cloudimage configuration. If, at this point, the image is missing from the Origin server, the return status code will be 404 (File Not Found) and it would looks like "the image cache expired earlier than the set up value". No, the image has never been cached in that local CDN server and it was requested for first time.
Our CDN partner has network of servers all around the globe and when you request an image URL you get response from the closest server to you considering your Geolocation . In case of heavy traffic your request may be sent to another server, located at a greater distance than the first one.
For this, you may get response from different servers while you are sitting at the same location.
Reason 2 – The s-maxage directive is indication how long maximum the local CDN server will use the cached file, if available, before to request again the original file. Any event that can lead to data lost may affect this value:
- CDN network update/server change
- Server storage clean up (on CDN or on local infrastructure level)
- Any sort of network crisis
Reason 3 – It may seems like the caching expiration period differs from the s-maxage value, is if you had changed the Cloudimage Caching settings and then forgot to invalidate the CDN cache.
After saving of any changes in the Caching tab of the Cloudimage Admin panel you need to perform Invalidation, otherwise the CDN PoPs continue to serve the image versions with the old caching period.
If you have some specific use-case and/or you would like to receive more information on the topic, feel free to contact us and we will be glad to help and to reply to all your questions.