Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
Added syntax highlighting to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjan van der Gaag committed Oct 28, 2011
1 parent 600e3fb commit e6fdebf
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions README.md
Expand Up @@ -29,7 +29,9 @@ install this gem:

Then load it via your project Gemfile or in `./lib/default.rb`:

require 'nanoc3/cachebuster'
```ruby
require 'nanoc3/cachebuster'
```

Usage
=====
Expand All @@ -41,21 +43,27 @@ replace any references to the regularly-named file to the rewritten one.

So, when you include a stylesheet:

<link rel="stylesheet" href="styles.css">
```html
<link rel="stylesheet" href="styles.css">
```

And you rewrite the output of the file to include a fingerprint:

# in your ./lib/default.rb
include Nanoc3::Helpers::CacheBusting
# in ./Rules
route '/styles/' do
fp = fingerprint(item[:filename])
item.identifier.chop + fp + '.css'
end
```ruby
# in your ./lib/default.rb
include Nanoc3::Helpers::CacheBusting
# in ./Rules
route '/styles/' do
fp = fingerprint(item[:filename])
item.identifier.chop + fp + '.css'
end
```

The filter will change your HTML on compilation to:

<link rel="stylesheet" href="styles-cb7a4bb98ef.css">
```html
<link rel="stylesheet" href="styles-cb7a4bb98ef.css">
```

You get simple, content-based cachebusters for free. All that is left for you
to do is set some far-future expires header in your server configuration.
Expand Down

0 comments on commit e6fdebf

Please sign in to comment.