Parse-server: Add Cache-Control support for Parse.Files / FilesRouter

Created on 21 May 2016  路  12Comments  路  Source: parse-community/parse-server

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 :)

enhancement up for grabs

Most helpful comment

Is the cache control available for non S3 file adapters?

All 12 comments

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

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!

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

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 :)

let's see how it goes!

Has cache control been added to the current S3 adapter?

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

Should probably close this issue to avoid confusion.

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

Is the cache control available for non S3 file adapters?

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!

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 ?

Was this page helpful?
0 / 5 - 0 ratings