Is AppEngine caching content?

63 views
Skip to first unread message

Iñigo Martínez de Ubago Vela

unread,
Nov 17, 2020, 9:29:49 AM11/17/20
to Google App Engine
Hi everyone!
I would like to expose a problem I'm facing with AppEngine services.
I have a Python application, based on Rest services.
I have one service which is in charge of upload a document and store it into a Cloud Storage bucket, create and identifier and store such identifier in a database,
For example:
POST /uploaddocument
Request body:
{
    "base64document":"base64_encoded_document"
}
Response:
{
    "document_id":"abc1234def5678"
}

Now, I have another service which retrieve such document from the storage, like this:
GET /retrievedocument?document_id=abc1234def5678
This service returns an "application/pdf" mime type.

For the moment everything works perfect. However, if I upload a new version of this document, the service "/retrievedocument" returns the old version, like if it would be cached, and request is not being processed by my service because I don't see any logs about this request. It is like this request would being served by a CDN or something like this, not by my application.
In addition, if I wait some time (more than an hour) then the request is again processed by my application and return the correct version of the document, like if cache would be expired.

I would like my service to be returning always the latest version of the document, not a cached one.

Have anyone of you faced this kind of problem any time?
Does anyone know how to solve it?

Thank you!

Kind regards,
Iñigo.

Elliott (Cloud Platform Support)

unread,
Nov 17, 2020, 2:52:00 PM11/17/20
to Google App Engine
Hello,

I think the first thing to do is recreate your scenario. Would you be able to provide functioning code to do so?

Iñigo Martínez de Ubago Vela

unread,
Nov 18, 2020, 3:44:51 AM11/18/20
to Google App Engine
Hi Elliot, thank you very much for your support.

Actually, it is not easy to isolate a pece of code to reproduce this scenario but, as far as I could find, it looks the behavior is like CDN caching, explained here: 

Specially, the part which talks about static files:

This is exactly the behavior I'm observing in my AppEngine service, I mean, I see how "application/pdf" responses are being cached. However, in case of CDN you can invalidate cache, but I don't know how to do that in AppEngine.
In my service, it is true that the request "/retrievedocument?document_id=abc1234def5678" returns an "application/json", however, I don't want it to be cached.

My understanding is that this would happen with all GET request which return "text/css", "application/javascript", "font/woff2", "image/jpg", "image/png", "video/mp4", "image/mpeg", "audio/mp4" and "application/pdf", according to CDN's documentation.

So, does anyone know how to avoid this?

Thank you very much.
Kind regards,
Iñigo. 

Christian Gonzalez

unread,
Nov 23, 2020, 9:07:56 AM11/23/20
to Google App Engine
Hello,
 
I think that by including the Cache-Control tag in the metadata pointing to no-cache as specified in this document should help us to avoid this https://cloud.google.com/storage/docs/metadata#cache-control
 
Could you please try this and let us know if this stopped the caching?
Reply all
Reply to author
Forward
0 new messages