I have SimpleCachingHeadersPageCachingFilter configured in my web.xml and it works fine but how would I go about adding some other stuff to the header like:
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
I went to http://ehcache.org/documentation/user-guide/web-caching for more info but no luck.
Everything is in the code and in JavaDocs. For starters I would extend
SimpleCachingHeadersPageCachingFilterand overridebuildPage():However JavaDoc for the method we are overriding states that:
SimplePageCachingFilteris a base class ofSimpleCachingHeadersPageCachingFilterwhich are extending right now. However I think this comment suggests to use the former class if we want to use completely different headers. If we want to keep standard headers (added by the latter class viasuper.buildPage()) this approach seems valid.Disclaimer: note that extending class’s behavior by extending it and overriding some methods by first calling
superversion and adding some logic isn’t the best OO technique.