// webpack.config.js
devServer: {
port:3,000
hot: true,
compress: false,
historyApiFallback: {
index: '/dist/index.html'
},
publicPath: '/dist/'
}
The Last-Modified header will be returned
No Last-Modified header. Only ETag is returned and no Cache-Control header.
Just run webpack-dev-server.
Not sure it is good idea, what is problem? Express sends headers, you setup this using options
@evilebottnawi,
Could you please help figure out where you disable the Last-Modified header?
As the express#express.static shows that lastModified is true by default. However, I couldn't see the header returned.
Recently, we have encountered a problem in our dev environment (Not served by webpack dev server):
The browser does not send the validation request to the origin server as it will assign a heuristic expiration time when there is no Cache-Control header but Last-Modified header returned.
Therefore, I want to know if you disable Last-Modified header on purpose.
Therefore, I want to know if you disable Last-Modified header on purpose.
No, it is bad idea
We have devServer.staticOptions https://webpack.js.org/configuration/dev-server/#devserverstaticoptions option for this
The browser does not send the validation request to the origin server as it will assign a heuristic expiration time when there is no Cache-Control header but Last-Modified header returned.
I can't understand problem(s), what do you mean "browser does not send the validation request to the origin server"? Please provide reproducible test repo, if it is bug we change behavior
@evilebottnawi,
I just created and started an app (my-app) by:
npx create-react-app my-app
npm start
or simple webpack configuration.
And I found that there was no any Last-Modified header returned for static assets (like js/css).
Therefore, I guess that you perhaps disable the Last-Modified header.
Maybe you can have a look at the response headers of static assets in your project. And I think there would be no Last-Modified header.
There is no bug with webpack-dev-server. I just want to know why there is no Last-Modified header returned for static assets.
Thanks!
Etag is sended by expresss, see reponse.js for details
To disable cache I set devServer.headers in webpack.config.js works fine
headers: {
'Cache-Control': 'max-age=0',
get etag() { return Math.random() + ''; },
},
@Otobelikethee the file served by webpack-dev-middleware won't add header Last-Modified , browser won't calculate heuristic freshness. However, express.static will add Last-Modified by default.
Maybe the assets you check are not served by express.static, hope it can help you
We have staticOptions for v4 https://github.com/webpack/webpack-dev-server/blob/master/lib/options.json#L12, so it is possible right now, sorry for delay
Most helpful comment
Etag is sended by expresss, see reponse.js for details
To disable cache I set
devServer.headersin webpack.config.js works fine