简体   繁体   中英

google cloud storage enabling caching and gzip compression on private content (javascript, css etc)

We have migrated our content from Akamai to google cloud storage, Akamai used to gzip content (javascript, CSS etc), now after moving to google storage this gzip compression is not happening which is impacting the performance of our site.

So my questions are :

  1. How to turn on gzip compression for private content. I have already tried few things like setting Content-encoding:gzip and few other but these are not working
  2. How to enable browser caching for these files again I have tried Cache-Control:public, max-age=10000, no-transform but no luck

All content in the bucket is already uploaded and private. Please also note that we have uploaded content as it is (not compressed) on google cloud storage.

Thanks in advance.

You need to compress the content before uploading; setting Content-encoding:gzip can be used to let the service automatically decompress for clients that don't set Accept-Encoding:gzip at download time. You get both when you use gsutil cp -Z, for example.

To enable caching you need to set the Cache-Control header as you did, but you also need to set the access control so the object is publicly readable. Caching is disabled for non-public data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM