One part you could do and i describe here is caching your css and js files which you should deliver always staticly. But the main problem of caching these links is the version tag at the end of each file link, cache mechanism won’t just recognize it as cachable content. To prevent loading static content like css and js files dynamicly we have to get rid with the version tag “?ver=x.xx” by Remove query strings from static resources on WordPress Links.
In this short tutorial i will describe a possible solution for wordpress and show you how to do this automaticly by strip off these version tags out of your links to get a better result in caching.
I hope you already have created a child-theme out of your primary theme template. This should be preferred because changes you apply to your files won’t get overwritten on next Theme update.
All we are going to do now is extending your functions.php with a specific replace code.
So open your functions.php with your preferred file editor and add the following code at the end of the file:
// remove version query string by https://ispire.me function _remove_query_string( $src ){ $parts = explode( '?ver=', $src ); return $parts[0]; } add_filter( 'script_loader_src', '_remove_query_string', 15, 1 ); add_filter( 'style_loader_src', '_remove_query_string', 15, 1 );
After applying this codeset, wordpress is replaces each occuring “?ver=” tag automaticly.
Have Fun with it!
HTTP/2 SSL Offloading with Hitch and Varnish Since Chrome browsers showing you insecure warning on…
File changed as we read it GlusterFS issue Recently i had trouble running Backups of…
Running multiple instances of varnish using systemd If you have not yet found a complete…
HTTP/2 SSL Offloading with Haproxy and Nginx After HTTP/2 becoming more an more prominent regarding SSL…
Get Real IP with Haproxy Tomcat Jira Confluence using x-forwarded-for Everyone knows the Problem. Get…
Review TDS2 How to backtest using tick data with Metatrader 4 in this Review TDS2…
This website uses cookies.
View Comments
Well done sir Jules... if you have minute to offer feedback on our plugin that allows for custom query string removal that would be super appreciated... positive or negative? Anyway thanks if possible!
https://wordpress.org/plugins/remove-query-strings-littlebizzy/
Nowdays i wouldnt recommend remove query strings from static resources anymore. GTMetrix e.g. should revise their complaints about it.
Its more important to have a cache busting feature for .js and .css files by appending query strings than serving outdated static files to clients due long persistent user caches which can lead into malformed page renderings