How to Control Caching on Shared Files

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
9/6/2013 5:46:02 AM
Gravatar
Total Posts 19

How to Control Caching on Shared Files

I can't find any information on setting cache headers for files in the Shared File module. I would like to set files to allow caching for 60 days. What is the best way to do this on MojoPortal?

 

 

9/6/2013 6:43:53 AM
Gravatar
Total Posts 18439

Re: How to Control Caching on Shared Files

why?

cache headers are for files downloaded automatically by the web browser ie images, css, js files, not for files the user clicks to download. Shared files is not intended for linking to files from other content it is intended for users to download by clicking in which case cache headers are be irrelevant, the file should download when clicked.

9/6/2013 9:22:14 AM
Gravatar
Total Posts 19

Re: How to Control Caching on Shared Files

Why? So the files will be cached and not downloaded over and over. I have a lot of PDFs that rarely change but the same users download them multiple times each week.

9/6/2013 9:48:37 AM
Gravatar
Total Posts 18439

Re: How to Control Caching on Shared Files

Sorry but when a user clicks to download it should download.

Shared Files is for sharing files securely by roles. The shared files download checks the user roles and if allowed it binary writes the file to the response and it should always do that if the user is allowed otherwise it would be broken.

Maybe you should consider not using Shared Files and just upload and link to pdf files in the content editor, then you have standard links to the files and server configuration for static files can be configured for cache.

ie create the text for the link in the html content editor, select the text and click the link toolbar button in the editor, click browse server, upload your pdf from there and link to it. 

Hope that helps,

Joe

9/6/2013 10:15:15 AM
Gravatar
Total Posts 18439

Re: How to Control Caching on Shared Files

Hi,

After thinking about this a bit more it would make sense for pdfs since the user is often viewing it right in the browser maybe the browser won't request the file url if it has it in the cache.

I will log a request in our project tracker to add support for cache headers.

Best,

Joe

9/6/2013 11:07:55 AM
Gravatar
Total Posts 19

Re: How to Control Caching on Shared Files

Thank you. That will be very helpful. 

9/6/2013 12:56:01 PM
Gravatar
Total Posts 18439

Re: How to Control Caching on Shared Files

fyi, I just implemented this.

If you put this setting in user.config then it will begin to work after the next upgrade of mojoPortal.

<add key="SharedFiles:NonAttachmentDownloadExpireDays" value="10"/>

9/6/2013 1:07:09 PM
Gravatar
Total Posts 19

Re: How to Control Caching on Shared Files

WOW Thanks. I haven't upgraded in a while but this will get me to it. 

 

P.S. Any plans for an MVC version of MojoPortal?

9/6/2013 1:11:36 PM
Gravatar
Total Posts 19

Re: How to Control Caching on Shared Files

Also.... 

The recent trend is to have a URL like http://www.YourDomain.com/SharedFiles/1.3.4/Download.aspx?fileid=20

where the version number changes if you update the file. That way you can set caching for long periods and then ensure that the latest file is downloaded irrespective of where it is cached (browser, proxy, etc...) 

That would be a great addition to the portal. 

9/6/2013 1:24:14 PM
Gravatar
Total Posts 18439

Re: How to Control Caching on Shared Files

Note that I mean after the next release of mojoportal, unless you are upgrading by building your own package from the source code repository, in which case it is in there now.

You must sign in to post in the forums. This thread is closed to new posts.