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