Install Cache-Control in a Google Cloud Storage Bucket

I have a bucket with public images that are often updated and would like to disable the default cache duration of 3600. (For example, "Cache-Control: private, max-age = 0, no-transform")

Is it possible to install Cache-Control into a file when downloading using PHP?

Is there a way to set Cache-Control by default for all future files in a bucket (for example, with an ACL that all files are public)?

Currently, I can only install it with Cache-Control using gsutil and only for files currently stored.

+4
source share
2 answers

Cache-Control - gsutil -D, , PHP:

gsutil -D -h Cache-Control:"Cache-Control:private, max-age=0, no-transform" \
    cp file gs://your-bucket/file

Cache-Control .

+2

: ? , , Cache-Control :

% gsutil -D -h Cache-Control: "Cache-Control: private, max-age = 0, no-transform" cp gs://my-bucket/file

...

INFO 0823 10: 31:19.517297 base_api.py] http POST https://www.googleapis.com/upload/storage/v1/b/my-bucket/o?fields=generation%2Ccrc32c%2Cmd5Hash%2Csize&alt=json&prettyPrint=True&uploadType=multipart INFO 0823 10: 31:19.517704 base_api.py] : {'accept': 'application/json',   "accept-encoding": "gzip, deflate",  'content-length': '444',  'content-type': "multipart/related; border = '=============== 6935917235018049421 ==' ',  'user-agent': 'apitools gsutil/4.5 (darwin)'} INFO 0823 10: 31:19.517773 base_api.py] : - =============== 6935917235018049421 == Content-Type: application/json MIME-: 1.0

{ "cacheControl": "Cache-Control: private, max-age = 0, no-transform", "bucket": "my-bucket", "contentType": "text/x-++", "name": "file", "contentLanguage": "en" } - =============== 6935917235018049421 == Content-Type: text/x-++ MIME-: 1.0 Content-Transfer-Encoding:

...

0

All Articles