Pragmatic Cache Invalidation

Server-side rendering is now part of the standard repertoire of websites and applications. even browsers like google chrome tend to cache as much as possible to minimize loading times of further calls. cache invalidation of css/js/image files can be solved with the help of mod_pagespeed, Expires/Cachecontrol header, a cache manifest or very pragmatically and directly by individual parameters behind the file name.


There are different strategies for when a file should be reloaded or not.

The simplest way is to reload on every request by appending a random string to the file to be embedded and thus force the reload (here an example of an image file):

2e634273f316c54b39828f057f7c7d9c

If that is too much of a good thing and instead only wants to reload when the file has changed, the date of the last file change is used (here using the example of a JS file):

2e634273f316c54b39828f057f7c7d9c

If you use version management such as Git , you can also use the unique hash of the last commit (the shortened version is sufficient) (here using a CSS file as an example):

2e634273f316c54b39828f057f7c7d9c

WordPress attaches the current WordPress version to all files integrated via enqueue_style and enqueue_script by default . This behavior can either be changed directly in the function calls as an argument, or you can hook yourself in globally and use one of the above methods:

2e634273f316c54b39828f057f7c7d9c

Back