ES6 modules allows us to create a single point of entry like so:
You can use ETags, as pointed out by a previous answer, or alternatively use Last-Modified in relation with If-Modified-Since.
Here is a possible scenario:
Last-Modified: Sat, 28 Mar 2020 18:12:45 GMT and Cache-Control: max-age=60.If-Modified-Since: Sat, 28 Mar 2020 18:12:45 GMT header. The server will check this value and:
200 response with the new file in the body.304 "not modified" status with empty body.I ended up with this set up for Apache server:
Header set Cache-Control "public, must-revalidate, max-age=3600"
Header unset ETag
You can set max-age to your liking.
We have to unset ETag. Otherwise Apache keeps responding with 200 OK every time (it's a bug). Besides, you won't need it if you use caching based on modification date.