Meteor-files: Feature request: `config.cacheControl` to accept a function

Created on 19 May 2017  路  5Comments  路  Source: veliovgroup/Meteor-Files

I would like to ask config.cacheControl to accept a function, additionally to the current string being already supported. The function should have a fileObj parameter and returns a string.

I am going to use it for my project.

It is useful when different types of files are in the same collection, and/or when the semantic associated with the files of the collection regarding their access right and/or immutability is different.

question

All 5 comments

Hello @green-coder ,

This is already possible via responseHeaders option.
See this tutorial

Let me know if it helps.

Thank you. It seems that it will fit my use-case, I will give it a try and close this issue later.

@green-coder thanks for feedback. Keep me updated, please.

I think it is a working solution.

In my use case the permissions on the audio files could change and we prefer not let the files too long on the client side when they shouldn't be there anymore.

Here is the lines I added into the responseHeader's default function, in the switch:

      default:
        if (fileRef.isImage) {
          headers['Cache-Control'] = 'public, max-age=31536000, s-maxage=31536000'
        }
        else if (fileRef.isAudio) {
          headers['Cache-Control'] = 'private, must-revalidate'
        }

Please, support this project by:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msgfxeg picture msgfxeg  路  3Comments

tuarrep picture tuarrep  路  4Comments

sylido picture sylido  路  3Comments

RE-N-Y picture RE-N-Y  路  3Comments

dr-dimitru picture dr-dimitru  路  3Comments