Web server with URL fingerprinting out of the box

by havoc

Years ago when we built Mugshot we stumbled on “URL fingerprinting,” Google describes it here. We used a “build stamp” (a continuously incrementing build number) instead of an MD5, but same thing. My guess is that many web sites end up doing this. Owen implemented the feature by writing a custom Apache module.

(The idea, if you aren’t familiar with it, is to give your static files an effectively infinite cache expiration time, but change their URL whenever the resource changes. If you have a bunch of JavaScript or CSS or whatever, people won’t have to re-download it on every visit to the site.)

It seems like the major web servers should do this out of the box. For a directory of static files, the web server could:

  • Generate a fingerprint for each file
  • Generate URLs containing the fingerprints
  • Communicate the fingerprint-containing URL back to the app server for use in templates (for example by writing out a simple text file with the mapping from original to fingerprinted URLs)
  • Set the infinite-expiration headers properly on the fingerprinted URLs

It is not a huge deal to script this yourself I guess, but do any web servers do this out of the box? Or maybe it’s a Varnish feature?

Ideally it’s dynamic, so if you change your static files the fingerprinted URLs automatically update.

My Twitter account is @havocp.
Interested in becoming a better software developer? Sign up for my email list and I'll let you know when I write something new.