java - Use Spring 3 filters to embed timestamp in resource paths? -
would work setup filters using spring 3 mvc paths javascript files , css files modified when streamed client, embedding timestamp in filename. , when resources later requested filter strips timestamps out?
this attempt prevent problems of cached js/css files when application redeployed
what need set up? how setup filter replace paths timestamp , how setup filter later strp timestamps out?
i need info on spring 3 mvc configuration in web.xml, ok actual code in filter need do
it may simpler use spring's resource mapping <mvc:resources>
, maps virtual path real location of css , javascript files. virtual path can contain version of application. means when deploy new version of application, path of css , javascript gets sent browser different before , fools browser thinking they're new resources - , reloads them.
for example map css , javascript files in /resources:
<mvc:resources location="/resources" mapping="/resources-1.2.0/**"/>
this says request comes in url pattern /resources-1.2.0 followed (e.g. /resources-1.2.0/css/styles.css), file in folder named resources in web root.
when update application version between deployments virtual path css , javascript resources change , browsers forced reload files - though real files in same old location.
you can make application version dynamic - don't need modify config file.
there's more in-depth write of whole approach here.
Comments
Post a Comment