disable caching for specific url in spring security

后端 未结 1 781
时光说笑
时光说笑 2020-12-11 12:45

in my situation i have four way to solve my problem:

  1. write meta config in my index.html and disable caching (doesn\'t work for me)
  2. chang
1条回答
  •  囚心锁ツ
    2020-12-11 12:55

    You can selectively add no cache headers to just index.html using Spring Security xml configuartion like this:

    
    [intercept-url, etc omitted...]
            
                
                
            
            
    
    
            
                
                    
                
            
            
                    
            
        
    

    However, the usual pattern if using Spring Security is to set no cache by default to all pages, and then selectively turn those headers off for static resources that

    • don't contain sensitive data
    • aren't dynamic

    To accomplish this feat, you have to explicitly define all headers you wish to apply in both cases, and select the pages via complementary request matcher patterns. For example, in an app where static, cacheable resources are found under /static and its subdirectories, and all dynamic pages mapped to controllers have the .htm extension, you can use this configuration:

            
    [...]
    
                
                
    
                
                
                
                
                
                
            
    
        
    
    
        
        
            
                
                    
                
            
            
                
                    
                        
                            
                                
                                
                            
                            
                                
                                
                            
    
                        
                    
                
            
         
    
        
        
            
                
                    
                
            
            
                    
            
         
        
            
                
                    
                
            
            
                    
            
         
            
            
                
                    
                
            
            
                    
            
         
            
            
                
                    
                
            
            
                    
            
         
            
            
                
                    
                
            
            
                    
            
         
    

    0 讨论(0)
提交回复
热议问题