To optimize the efficiency of browser cache usage for static files, I am seeking a way to always utilize cached content unless there has been a change in the file, in which case fetching the new content is necessary.
My goal is to append an md5 hash of the file to the virtual file path that the client sees. This could be done either as part of the directory or as part of the file name itself. By doing so, when the file undergoes changes, the client perceives it as a distinct resource.
I have knowledge of using a servlet filter to intercept requests containing the virtual file path and strip the md5 hash to reveal the actual file name within the directory structure.
In addition to this, I am interested in understanding if it's possible to use a filter to modify the apparent file name on the way out. Thus, give the impression to the client's browser that it is requesting the virtual file path without altering the real names or directory structures of the physical files themselves.
For instance:
Original file path = /css/1.css
Virtual file path = /static/1234/css/1.css
Upon file modification:
Real file path = /css/1.css
Virtual file path = /static/3451/css/1.css