0
votes

I'm trying to set the read_cache_expiry_seconds option to some user uploads, but the files seems to be cached by 3600 seconds (default) instead the value I want.

The resource context I'm adding is the following:

        $_defaultMetadata = [
                            'gs' => [   
                                        'enable_cache' => true,
                                        'enable_optimistic_cache' => false,
                                        'read_cache_expiry_seconds' => 60,
                                        'Cache-Control' => 'public, max-age=60'
                                    ]
                            ];
        $ctx = stream_context_create($_defaultMetadata);
        file_put_contents( 'gs://' . $bucketPath,  $data, 0 , $ctx);

Any idea why this context is not working ?

How do you know that the items are being cached for 3600 seconds and not 60? - Stuart Langley
Because I'm replacing the object and it returns the same headers for an hour (content-length) - Emilio Borraz
So you mean the Cache-Control header not the read_cache_expiry_seconds value? How are you reading the headers? From a GCS public URL? - Stuart Langley
I mean the read_cache_expiry_seconds, not the Cache-Control header. By reading the headers I mean from a public URL, each time I update the object, it delays to give me the right Content-Length value. If I add a URL parameter (?para=randomVal) to the public URL it gives me the correct Content-Lenght value. - Emilio Borraz
the two are not related - read_cache_expiry_seconds sets how long we store the file in memcache on app engine to make the reads faster. it has nothing to do with serving the file from the public URL. - Stuart Langley