Closed cessda-bitbucket-importer closed 3 years ago
Original comment by Matthew Morris (GitHub: matthew-morris-cessda).
Hi Sigit,
The first issue I can see is that the HTTP cache-control
header is set to max-age=126230400000, public
, which means that browsers, as well as any other cache, will cache the response for 4,000 years.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
It would be better to use a more reasonable max-age
parameter, as well as using the no-cache
directive. Using no-cache
will cause clients to always recheck with the server if a newer resource is avaliable.
A side note is that the json is served with the incorrect text/html
mime type, it should use application/json
.
Original comment by Matthew Morris (GitHub: matthew-morris-cessda).
I’ve created a PR to fix the incorrect MIME type
[link to pull request removed](link to pull request removed)
Original comment by sigit nugraha.
@matthew-morris-cessda
Thanks to point that out.
Yes, I forgot to set the default JHipster cache configuration of 4 years.
Now I have set the max-age to 0
And test it on the dev system. so far seems ok.
Is it possible if you directly deploy this one change to the production? or I need to use the normal procedure (create a changelog, increase the app version number and tag, and create a git issue for the deployment).
Original comment by sigit nugraha.
@matthew-morris-cessda
Sorry, I did not see your last comment, since I did not refresh the Bitbucket page.
Thank you for the PR I have it tested and yes the header params are now correct.
I have approved and merged the PR.
To request the production deployment, should I do the usual normal procedure?
Original comment by Matthew Morris (GitHub: matthew-morris-cessda).
Please do. I'll mark this issue as resolved.
Original comment by sigit nugraha.
Change cache control from no-cache to no-store #300
Original report on BitBucket by sigit nugraha.
Hi @Joshocan & @matthew-morris-cessda
There is a blocker issue #296, which mentioned that the recently published CV sometimes does not appear on the publication side. I think this is related to the cache in the Google Cloud side, which does the caching for the publicly accessible static files. The published CVs are stored in static JSON files, which are updated every time the user publishes a version of Vocabularies.
Do you know whether it is possible to prevent Google Cloud from caching the files located on /content/vocabularies? for example:
https://vocabularies.cessda.eu/content/vocabularies/SamplingProcedure/SamplingProcedure.json
I have tested by retrieving the JSON files from the above link (with cache disabled on Postman/Web-Browser), and as you can see from the file size, that the JSON files retrieved from Google cloud are mixed between the current version and the older cached version.
Which causing sometimes the DE version to disappear on the Samplig Procedure
The static JSON files are currently used for the publication side and the /v2 rest APIs. so they are really important not to be in cached. If it is not possible to prevent this google-cloud cache, then probably I need to move the storage of published vocabularies to the database which is major change.
Update:
Turns out that the issue is due to incorrect HTTP Headers (4 years max-age & incorrect content type). Thus, the title of the issue is updated from “Prevent the cache of the published-Vocabularies stored in the static JSON files“ to “Fix incorrect HTTP headers related to cache-control and content-type for JSON files“