Right now files uploaded via ActiveStorage with the GCS Service default to
This is particularly problematic for Google Cloud CDN, since it only caches assets that are public:
Cloud CDN caches only responses that are marked public and specify an expiration time or maximum age. This information is conveyed in HTTP response headers. If responses for a URL aren’t being cached, check which HTTP headers are being returned for that URL.
ActiveStorage’s architecture involves a 302 redirect to the underlying asset. Without a CDN for the GCS scenario, the performance implications of a highly trafficked site to also have to redirect wouldn’t be stellar. But perhaps this is only a GCS problem, since I know AWS will cache content regardless of the cache-control header.
My proposed solution for this is to allow a developer to configure headers in the config/storage.yml on a per service basis:
cache_control: public, max-age=31556926
Ultimately, I believe developers will occasionally need a way to set headers on the files uploaded via ActiveStorage by the non Disk services. I would love to hear better alternatives if there are any.