java - Send specific headers on MIME-type response in Apache Tomcat -
i have apache tomcat server running. if have like:
webapp/ image1.png then, can access using:
example.com/image1.png which perfect, except don't have control on headers being sent. wish send specific expires header mime-types (like, image/png). these headers static, don't mind if have specify in xml file , cannot dynamic.
is possible apache tomcat? other obvious way read file , output browser appropriate headers, think might overkill.
use tomcat filters applying headers.
<web-app ...> ... <filter> <filter-name>expiresfilter</filter-name> <filter-class>org.apache.catalina.filters.expiresfilter</filter-class> <init-param> <param-name>expiresbytype image</param-name> <param-value>access plus 10 minutes</param-value> </init-param> <init-param> <param-name>expiresbytype text/css</param-name> <param-value>access plus 10 minutes</param-value> </init-param> <init-param> <param-name>expiresbytype application/javascript</param-name> <param-value>access plus 10 minutes</param-value> </init-param> </filter> ... <filter-mapping> <filter-name>expiresfilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>request</dispatcher> </filter-mapping> ... </web-app> more info @ tomcat filter documentation
Comments
Post a Comment