Front-end css/js/html file cache

when a user uses Ctrl+F5 to force a page refresh, the css/js/html file is reloaded.

if the css/js/html file is not modified, it will take a long time to reload.

after looking up the data, you can determine whether the file has been updated by adding a hash value to the file suffix; this method is suitable for modifying the file so that the browser overwrites the old file.

but for now, what I want is for the user to use Ctrl+F5 to force the page refresh, but because the css/js/html file hasn"t changed, it doesn"t have to reload, just read the cache.

is there any way to achieve this requirement?

Oct.22,2021

your requirement cannot be realized, first of all, you need to know how the server determines whether it needs to be updated; secondly, when Ctrl+F5, the browser will not carry any identification


pseudo requirements.
< kbd > Ctrl < / kbd > + < kbd > f5 < / kbd > originally forcibly refresh the cache, how can it be loaded according to the cache? Just make the browser cache policy normally, regardless of whether the user refreshes with < kbd > f5 < / kbd > or < kbd > Ctrl < / kbd > + < kbd > f5 < / kbd >.


aside from the requirements, please find out what Ctrl+f5 is for.
Ctrl+F5 wants to get a new resource from Server completely, so not only do you have to send HTTP request to Server, but there is no If-Modified-Since/If-None-Match in this request, thus forcing Server not to return 304. Instead, return the entire resource to the original
reference: browser: the difference between F5 and Ctrl+F5

Menu