We have experienced in WordPress that it generates automatically query string URL by adding a “?” question mark inside of a URL. Which is somewhat not cacheable by most proxies and notably squid up through version 3.0 even if a cache-control:public header is present in response. What actually I mean is that in order to speed up a website we need it to be cleaned up from untidy query string URLs… Let me tell you a little bit more about those files which are being caused with query string URL. Mostly these files are CSS or JS…

Removing Query string URL from WordPress

Here are some examples about query string URLs:

http://1.gravatar.com/avatar/da2d44be2b1df905b5e297f7ee754c4f?s=65&d=&r=G
http://softstribe.com/wp-content/plugins/wp-table-reloaded/css/datatables.css?ver=1.9.4
http://softstribe.com/wp-content/plugins/wp-table-reloaded/css/plugin.css?ver=1.9.4

You can see at the end of each URL mentioned above has a question mark and now the next parameters after “?” in the URL will be termed as query string URL.

How to Remove Query String URLs?

In this article I’m going to show you how to remove query string “?” from static resources especially. What we are going are to do is actually adding simple line of codes inside of our functions.php file before the closing php tag ?>.

function _remove_script_version( $src ){ 
$parts = explode( '?', $src ); 	
return $parts[0]; 
} 
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); 
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

Save the file and try testing it again… Hope you will find your website cleaned by 100%.