I have a VueJS app. Whenever I run npm run build it creates a new set of dist/* files, however, when I load them on the server (after deleting the
If you use asp.net core you can try the following trick among with the webpack which generates js files with the hash at the end of the name eg. my-home-page-vue.30f62910.js.
So your index.html contains:
which means whenever you change the my-home-page.vue it will generate a new hash in the filename.
The only thing you need is to add a cache restriction against the index.html
In your Startup.cs:
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
// ....
app.UseStaticFiles(new StaticFileOptions
{
// Make sure your dist folder is correct
FileProvider = new PhysicalFileProvider(Path.Combine(_env.ContentRootPath, "ClientApp/dist")),
RequestPath = "",
OnPrepareResponse = context =>
{
if (context.Context.Request.Path.StartsWithSegments("/index.html", StringComparison.OrdinalIgnoreCase))
{
context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store");
context.Context.Response.Headers.Add("Expires", "-1");
}
},
});
// ....
}