简体   繁体   English

在ASP.NET Core 2.0上刷新静态HTML缓存

[英]Refreshing static html cache on asp.net core 2.0

I'm busy building a website using asp.net core 2.0, and it's hosted on a Ubuntu 16.04 server with Nginx acting as a proxy. 我正忙于使用asp.net core 2.0建立网站,并且该网站托管在Ubuntu 16.04服务器上,并以Nginx作为代理。 It's not a live environment but a local. 这不是一个生活环境,而是一个本地环境。

What I would like to know is, when updating static view's, eg. 我想知道的是,例如在更新静态视图时。 the about page with extra content, and upload it to the dev server, it does not update until I restart the service that the site is running under. 关于页面,其中包含额外的内容,并将其上传到开发服务器,直到我重新启动该网站所运行的服务后,它才会更新。 Is there any way to get around that, so that when I upload the content, it automatically refreshes. 有什么方法可以解决这个问题,以便当我上传内容时,它会自动刷新。

I've used this guide to setup Nginx and asp.net core 2.0 on the Ubuntu server : 我已经使用本指南在Ubuntu服务器上设置Nginx和asp.net core 2.0:

https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction?tabs=aspnetcore2x https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction?tabs=aspnetcore2x

You should be serving static files directly from nginx instead of doing it through .NET 您应该直接从nginx提供静态文件,而不是通过.NET进行操作

Assuming you have /css , /js for your assets located in your /www/inetpub/assets folder then you would add below to your nginx config 假设您的资产位于/www/inetpub/assets文件夹中,则具有/css/js ,那么您可以将以下内容添加到您的nginx配置中

location ~* ^/(css|js)/ {
   root /www/inetpub/assets;
}

This will server css from /www/inetpub/assets/css folder 这将从/www/inetpub/assets/css文件夹服务器css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM