Visual Studio Development Server not updating css and javascript?

后端 未结 4 1178
悲哀的现实
悲哀的现实 2020-12-09 08:46

I\'ve recently returned to a web site project that has been on the backburner. Since recommencing work I\'ve noticed css and javascript changes aren\'t being recognised by

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-09 09:34

    If you always want to get the last version of js and CSS files, you could modify your StaticFile middleware like

    app.UseStaticFiles(new StaticFileOptions()
    {
        OnPrepareResponse = context =>
        {
            context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store");
            context.Context.Response.Headers.Add("Expires", "-1");
        }
    });
    

    or you could add asp-append-version="true" to your file references like:

    
    

提交回复
热议问题