I created a website on Google-Appengine. To reduce the costs of Google-Cloud-SQL my API generates public json-files from Cloud-SQL in my Google-Cloud-Storage that should be read by my Android-App and my Website (via ajax).
The Problem is, that the files of Google-Cloud-Storage are automatically cached for an hour, but I want to disable caching for specific files.
If I upload a file manual in the Developers Console I may change this behaviour with a click on "Edit Metadata" and setting Cache-Control to private, max-age=0,no-transform
(see the following picture). Then if I try to access this file, I get the wanted header private, max-age=0,no-transform
But in my application the json-files are generated by PHP and I always get the header cache-control → public, max-age=3600
. I create the files with the following code (Here is the official docs: Docs):
$options = ['gs' => [
'Content-Type' => 'text/json',
'acl' => 'public-read',
'enable_cache' => false,
'read_cache_expiry_seconds' => 0]
];
$ctx = stream_context_create($options);
file_put_contents($url,$content,0,$ctx);
Has anybody an idea why caching is not turned off?