Set Cache-Control Header for Alfresco Content

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Set Cache-Control Header for Alfresco Content

I'm using Alfresco to store PDFs for my web application. However, when requesting these files directly, e.g. via

 

https://example.com/alfresco//download/attach/workspace/SpacesStore//b1b6f82c-e09a-4f99-b9be-01aed2f...

the HTTP Cache-Control Header is set to "must-revalidate, max-age=0". This prevents the browser to cache these requests. 

How can I modify this header? Alfresco Vers. 5.0

7 Replies
Highlighted
Senior Member II

Re: Set Cache-Control Header for Alfresco Content

Are you using tomcat directly or a http server as reverse proxy (what you should do)?

for tomcat, you can manage cache control with the "expires filter", see Apache Tomcat 7 Configuration Reference (7.0.77) - Container Provided Filters 

Active Member

Re: Set Cache-Control Header for Alfresco Content

Directly from Tomcat. Why should I use a proxy?

Going to read the documentation, thanks!

Highlighted
Senior Member II

Re: Set Cache-Control Header for Alfresco Content

I use a reverse proxy, because I can configure static content to be delivered by the http server, can display a friendly maintenance page for alfresco when it's down, handle https with the httpd, can hide my nodejs or angular SPAs behind the reverse proxy and use the same sitename (and avoid corse problems), can easily switch to a backup alfresco....

Highlighted
Active Member

Re: Set Cache-Control Header for Alfresco Content

I used the code provided at the documentation page of Tomcat but it still responds with "must-revalidate, max-age=0". 

Here is my web.xml: https://pastebin.com/GhXFh0jd (the ExpiresFilter is at the bottom). Does the "CacheExpiresFilter" influence the "ExpiresFilter" somehow? 

Any ideas or should I post this at a Tomcat forum? 

Highlighted
Senior Member II

Re: Set Cache-Control Header for Alfresco Content

can you try to comment out the secure-comms section (you cannot communicate with solr then, but just for a test)?

Maybe the existence of a security-constraint disables the setting of the ExpiresFilter.

I disabled the https communication between solr and the repo, because the are livin' on the same server - but this is another story...

Highlighted
Active Member

Re: Set Cache-Control Header for Alfresco Content

I commented out the secure-comms section, but still the same result. 

By the way, I'm modifiying ./tomcat/webapps/alfresco/WEB-INF/web.xml - I hope this is the correct file? 

Highlighted
Senior Member II

Re: Set Cache-Control Header for Alfresco Content

this would be the correct file for repository urls - if you put it in tomcat/conf/web.xml the filter would also be active for share...

But, I didn't read your question as carefully as I should. You can influence tomcats delivery of elements with the filter - but for the content-servlet this is most likely overridden by alfresco, because alfresco wants to make sure that you always get the current version of the nodes content (In the meantime some could have created a new version).

I fear you have to write your own content servlet if you want to set the max-age header - or put a http server in front of tomcat to manipulate the header for the ../download/... url.