Remove query strings from static resources
Home
From the Google page speed:
Resources with a "?" in the URL are not cached by some proxy caching servers. Remove the query string and encode the parameters into the URL for the following resources:
* http://beta.holidayextras.co.uk/javascripts/cache/application.js?1297952648
So we're using ruby on rails and it puts that ?1297952648 on the end of the resources to force them to reloaded if we've changed the file since you last saw it. On other sites, including this one and holidayextras.co.uk we're doing it by mangling the name of the file as we output the page the file is used in, and then using a .htaccess rule to make the file name right again... so if I have an image called valid.png, instead of putting it in the page with
<img src=valid.png />I put this fake number in the file name:
<img src=valid.98979879.png />valid.98979879.png does not exist, I'm never actually renaming the image. So your browser requests valid.98979879.png which doesn't exist, but I have this rule in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).[0-9]+.(w+)$ $1.$2 [C,E=VERSIONED_FILE:1]
</IfModule>
which sends you the right file. And then if I chuck this in too:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/png "access plus 2 years"
</IfModule>Then I get nice fast page speed skills!
Why doesn't rails have that built in by default?
pauly :: 2011 :: Comment / reply
Over to you, discussion about anything local, but please be considerate... Folkestone on TV, Kent gigs, Find a flatmate, rent a room, property queries, current news, what's new, local events, for sale, local services, what I like about Folkestone, ask questions, offer advice, plug yourself... the more it's used the more useful a resource it will become. If you want a gig listed click here to add it (fixed now!), or just click here to post a message...
Also from the same week
Some more blog posts from the same week as .
When did Brendan Sheerin (from Coach Trip) live in Folkestone? [Monday 14 February 2011]
More on The Vibrations who played Toft's in 1966 Courtesy of garagehangover.com... [Tuesday 15 February 2011]
RE: Has The Harbour been renamed The True Brit? [Thursday 17 February 2011]
Pictures of Dover past and present [Thursday 17 February 2011]
Leas Lift Beer Festival 25th and 26th Feb [Friday 18 February 2011]
Has The Harbour been renamed The True Brit? [Wednesday 26 January 2011]
RE: Has The Harbour been renamed The True Brit? [Tuesday 22 February 2011]
Interesting rumour about Noel Gallagher! Always seems to be someone moving to Sandgate... [Tuesday 22 February 2011]
RE: Interesting rumour about Noel Gallagher! [Wednesday 23 February 2011]
Any celebrity neighbours add a little something to the area [Wednesday 23 February 2011]

