How can we enable caching for Bundles in MVC5

后端 未结 2 503
温柔的废话
温柔的废话 2021-01-23 13:20

I have created 2 bundles in my mvc project as given below:

 public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBund         


        
2条回答
  •  盖世英雄少女心
    2021-01-23 13:46

    MVC bundles are returned as a single static file to browsers whose cache time is set to 1 year by default. ASP.NET MVC takes care of change tracking of your bundle files and changes bundle url if content of any file is changed or a file is being added / removed from bundle.

    As bundles are already cached and change tracking is maintained by asp.net mvc framework, what else cache control do you want on those bundles?

    EDIT (in response to comment)

    Unfortunately you can not alter that limit. Cache limit is handles by ProcessRequest method of BundleHandler class and this is internal sealed so there is no chance that you can inherit \ override these requests.

    For further details you can refer this question.

提交回复
热议问题