Tomcat: Cache-Control

前端 未结 6 703
悲哀的现实
悲哀的现实 2020-11-30 19:19

Jetty has a CacheControl parameter (can be specified webdefault.xml) that determines the caching behavior of clients (by affecting headers sent to clients).

Does Tom

6条回答
  •  Happy的楠姐
    2020-11-30 20:12

    Since Tomcat 7 there is a container provided expires filter that may help. See:

    • https://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Expires_Filter
    • https://tomcat.apache.org/tomcat-8.0-doc/config/filter.html#Expires_Filter
    • https://tomcat.apache.org/tomcat-9.0-doc/config/filter.html#Expires_Filter

    ExpiresFilter is a Java Servlet API port of Apache mod_expires. This filter controls the setting of the Expires HTTP header and the max-age directive of the Cache-Control HTTP header in server responses. The expiration date can set to be relative to either the time the source file was last modified, or to the time of the client access.

    
        ExpiresFilter
        org.apache.catalina.filters.ExpiresFilter
        
            ExpiresByType image
            access plus 10 days
        
        
            ExpiresByType text/css
            access plus 10 hours
        
        
            ExpiresByType application/javascript
            access plus 10 minutes
        
        
        
            ExpiresDefault
            access plus 0 seconds
        
    
    
    
        ExpiresFilter
        /*
        REQUEST
    
    

提交回复
热议问题