CSS in App_Theme folder gets Cached in Browser

前端 未结 5 1699
庸人自扰
庸人自扰 2020-12-11 05:35

The Stylesheet in the App_Theme folder gets cached in the browser. What should be the approach? so that whenever there is a new deployment the browser should take the latest

5条回答
  •  被撕碎了的回忆
    2020-12-11 05:51

    When deploying the web application, include the version number in the themes path. For example, App_Themes/Default/v1.2.0.4321/, where v1.2.0.4321 is the folder added at deployment for version 1.2.0.4321. This preserves both the theme name (e.g., "Default") and the file names, which makes source code control and path references much easier. ASP.NET loads all of the CSS files in the current theme folder regardless of subfolders. This not only solves the problem referencing CSS files, but images that are referenced from within the CSS files (e.g., background-image).

    Additionally, the browser cache duration for App_Themes may be increased to improve performance while ensuring that the next time the web application is updated, all the theme files will be updated.

    Add this to the section of the Web.Config to have the browsers cache for 120 days.

    
        
            
                
            
        
    
    

提交回复
热议问题