A very long time have been passed since I have covered some topic over Drupal development, sorry for that.

Today I would like to show how one (perhaps you) can remove query strings from static resources (and I'm speaking of CSS resources exclusively)

Time after time I'm heading to tools.pingdom.com just to test how my blog or some other project I'm working with is performing. I got a pretty good scale of 78 (out of 100), two things were reported has a room to improve:

  • Remove query strings from static resources
  • Specify a Vary: Accept-Encoding header

And I started searching for options to improve one of them, and I found an excellent solution on github

Add to your Drupal template.tpl file following code:

<?php /** * Implements template_process_html().
*/
//
Remove Query Strings from CSS filenames (CacheBuster)
function MYTHEME_process_html(&$variables) {
$variables['styles'] = preg_replace('/\.css\?[^"]+/','.css', $variables['styles']);
}
 ?>
Make sure to rename MYTHEME to your theme's name and then just clear Drupal's cache and check again your results on tools.pingdom.com. 
I improved score for my blog from 78 to 82.

This will solve just a half of the problem - this will remove just query strings from CSS file names, but with little adjusting (haven't yet solved) you could strip .js query strings as well.