parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Add Cache-Control support for Parse.Files / FilesRouter

Open andresgarza opened this issue 10 years ago • 12 comments

Currently, the FilesRouter sets no response headers other that the Content-Type of the file being requested. It would be great if we could somehow configure also sending a Cache-Control header for file requests.

One idea would be for each Parse.File to specify its cache mechanism (by default it could have caching disabled). Another idea is to have a "global" caching mechanism that could work as a default.

I would gladly help submitting a PR if someone could point me in the right direction :)

andresgarza avatar May 20 '16 22:05 andresgarza

This is a great idea. @skinp has done most of our files related code, hopefully he can point out where this might be added.

drew-gross avatar May 21 '16 01:05 drew-gross

Any update on this?

I implemented CloudFront support using my AWS S3 storage. But running the PageSpeed Insights from Google suggests that my files don't have Cache-Control: (expiration not specified).

Thanks!

KBog avatar Jul 19 '16 02:07 KBog

Not yet, but your could take over @KBog . Also you coud implement it into the https://github.com/parse-server-modules/parse-server-s3-adapter as a global cache control for all s3 uploaded files

flovilmart avatar Jul 19 '16 02:07 flovilmart

Here's my attempt to add the global cache control as you suggested: https://github.com/parse-server-modules/parse-server-s3-adapter/pull/13

I made the change locally at first (localhost), and was able to see (in Chrome debugger) the "Cache-Control" being added to newly saved Parse.Files.

Pardon any newbie mistakes, as I'm still a beginner when it comes to web/server dev :)

KBog avatar Jul 19 '16 03:07 KBog

let's see how it goes!

flovilmart avatar Jul 19 '16 03:07 flovilmart

Has cache control been added to the current S3 adapter?

bchapin avatar Dec 15 '16 18:12 bchapin

Yes, it's been out for a while. Tested it and working in our production app.

KBog avatar Dec 16 '16 04:12 KBog

Should probably close this issue to avoid confusion.

KBog avatar Dec 16 '16 05:12 KBog

I believe the cache-control only works if you are accessing the files directly through S3 (directAccess=true).

andresgarza avatar Dec 16 '16 05:12 andresgarza

Is the cache control available for non S3 file adapters?

yaaminu avatar Jul 31 '17 14:07 yaaminu

Looks like this has been added to the S3 adapter but was never closed out. Taking care of it now, let us know if we're missing anything and this needs be reopened!

montymxb avatar Sep 10 '17 02:09 montymxb

Looks like this has been added to the S3 adapter but was never closed out. Taking care of it now, let us know if we're missing anything and this needs be reopened!

I just read this thread looking for an answer. If I'm right, the initial question has never been answered and this is still not an option for the standard FilesRouter. Is there any option to set the Cache-Control header with the standard GridFS adapter ?

thibautvdu avatar Feb 19 '20 02:02 thibautvdu