DLFileEntry from Document library are downloaded from WebServerServlet, that is adding Cache-Control: private header but no other caching instruction (like max-age or Expires) is appended.
ServletResponseUtil will override the Cache-Control header, no matter what was set before. In this particular case, when trying to modify the header using the HeaderFilter will fail because the portal will override it with a hard-coded value later on.
Overwrite Cache-Control headers settings.
- Shut down the portal.
- Edit the <tomcat_home>/webapps/ROOT/WEB-INF/liferay-web.xml
- Add the following filter mapping:
<filter-mapping>
<filter-name>Header Filter</filter-name>
<url-pattern>/documents/*</url-pattern>
</filter-mapping>
I’ve added it after the following block:<filter-mapping>
<filter-name>Header Filter</filter-name>
<url-pattern>*.png</url-pattern>
</filter-mapping>
Start the portal again.
Check Header detail in the brwoser.
Before configuration change
URL: https://localhost:8080/documents/20197/983069/bim-fp.jpg/8177e209-45b9-43b1-8311-9cc5230e8973?t=1463000778069
Result: This should have “Cache-Control: private”
After configuration change
URL: https://localhost:8080/documents/20197/983069/bim-fp.jpg/8177e209-45b9-43b1-8311-9cc5230e8973?t=1463000778069
Result: This should have “Cache-Control:max-age=315360000, public”
Leave a Reply