无法在spring-boot上设置自定义标头以防止缓存控制

时间:2017-08-15 02:40:13

标签: angular spring-boot spring-security

我注意到我的应用程序在IE中运行不正常,因为每次用户尝试刷新数据时,他都会从服务器获取代码304 我确保我的前端在每个请求中发送两个标头

  

'缓存控制' :' no-cache',           Pragma:' no-cache'

当我检查请求时,我注意到以下内容,自定义标头不在那里! missing headers

UPDATE -response标题

enter image description here

我以为我可能会在我的弹簧靴V1.53上遗漏一些东西 所以我添加了以下内容

@Override
    protected void configure(HttpSecurity http) throws Exception {

        log.debug("Proceeding to configure http security");

        http.exceptionHandling().authenticationEntryPoint(entryPoint).and()
                .addFilterBefore(waffleFilter, UsernamePasswordAuthenticationFilter.class);

        http.authorizeRequests().antMatchers("/dashboard").hasAnyAuthority(allowedRoles);

        http.authorizeRequests().antMatchers("/api/read/**").hasAnyAuthority(allowedRoles);




        http.authorizeRequests().antMatchers("/**").denyAll();

        http.headers().cacheControl().disable();
        http.headers().addHeaderWriter(new StaticHeadersWriter("Cache-Control","no-cache"));
        http.headers().addHeaderWriter(new StaticHeadersWriter("Pragma","no-cache"));




        http.exceptionHandling().accessDeniedHandler(accessDeniedHandler());

    }

但这并没有改变任何事情 我试图添加以下属性

spring.resources.chain.cache=true
security.headers.cache=false

仍然没有标题 我用chrome和IE测试过但是我可以看到我的自定义标题

值得一提的是我的前端是angular4,当我在本地测试时 使用ng服务,我可以看到两个自定义标题

0 个答案:

没有答案
相关问题