I am using pre-signed url for frontend image display. However, each time the page is reloaded a new pre-signed url is generated from the backend. As each url to the same image is different, I am not sure if this is cache-friendly. In AWS’s CloudFront they have pre-signed-cookies. The URL will always be the same for the browser, and the permission is stored in the cookies. Does Digital Ocean have something similar? Or do I have to cache the pre-signed urls myself to avoid high bandwidth width? Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
DigitalOcean Spaces CDN doesn’t have a direct equivalent to AWS CloudFront’s pre-signed cookies, but you can still improve caching while using pre-signed URLs.
The main issue is that every time a new pre-signed URL is generated, browsers and caches treat it as a completely new file, preventing efficient caching.
One option is to use a fixed URL with longer expiration times instead of generating a new pre-signed URL on every request. If the images don’t change frequently, setting a longer expiration time for the signed URL can allow browsers to cache it properly. Another important step is configuring Cache-Control headers correctly. If your assets are static, using Cache-Control: public, max-age=31536000, immutable will allow the browser to cache the file long-term without checking for updates.
If you need more control, you can implement a caching mechanism in your backend, storing valid pre-signed URLs in memory (e.g., using Redis) and serving the same URL to users within a given timeframe.