04-12-2017 10:59 AM
I'm using Alfresco to store PDFs for my web application. However, when requesting these files directly, e.g. via
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
04-12-2017 11:33 AM
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
04-12-2017 12:40 PM
Directly from Tomcat. Why should I use a proxy?
Going to read the documentation, thanks!
04-12-2017 12:59 PM
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....
04-13-2017 11:17 AM
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?
04-13-2017 12:02 PM
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...
04-13-2017 02:01 PM
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?
04-13-2017 04:24 PM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.