We have a bunch of .js files in a web application which are not located under a single directory. UI was developed separately and it is pretty time consuming to redesign it to have all the *.js files in one place.
The problem is that those files are cached by browsers pretty heavily and this creates a lot of issues with every application update. And we decided to turn off caching for those files.
So, *.js files were included into servlet mapping:
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
I have tried using mvc:resources but it does not handle url’s masks like this:
<mvc:resources mapping="*.js" location="*.js" cache-period="0"/>
This doesn’t work and I have 404 response back when I am trying to access a js file.
I have also tried mvc:interceptor:
<mvc:interceptor>
<mvc:mapping path="*.js"/>
<bean id="webJSContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptor>
This results in 404 error as well.
Is this type of thing possible?
This is not possible. But there are several options: