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
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
Directly from Tomcat. Why should I use a proxy?
Going to read the documentation, thanks!
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....
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?
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...
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?
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.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.