Don't set cache for different parts of spring mvc 3 using WebContentInterceptor?

Hi, I have developed a dynamic web application that uses Ajax to retrieve data from databases and update the GUI, but when testing it with IE8 I have problems with caching.

I used the following code in the webmvc-config.xml file to stop caching:

<mvc:annotation-driven /> <mvc:interceptors> <bean id="webContentInterceptor" 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:interceptors>

and it works exactly as it should, but the problem is that the browser is now clearly not caching anything. I want to know how to change this xml code so that it applies to parts of the Ajax web application (which are managed using 5 Controller files); so are the ..etc icons still cached? The path to these controller files will look like "/ admin / **"

I know that Spring WebContentInterceptor has properties such as "setCacheMappings" and "setPathMatcher", but there is nowhere else on the Internet that I can find examples of using these files in the xml configuration file.

ANY help would be greatly appreciated, it really makes my head in .. Thanks. Jake

+4
source share
1 answer

In <mvc:interceptors> you can limit the URL path to which each interceptor should apply, as follows:

 <mvc:interceptors> <mvc:interceptor> <mapping path="/admin/*"/> <bean id="webContentInterceptor" ..... /> </mvc:interceptor> <mvc:interceptors> 

Everything is explained here .

+11
source

Source: https://habr.com/ru/post/1338025/


All Articles