Skip to content

Commit

Permalink
Reflect the new explicit asset change detection strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Dec 4, 2012
1 parent 233e393 commit f0213d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ Also, Turbolinks is installed as the last click handler for links. So if you ins
Asset change detection
----------------------

Turbolinks will remember what assets were linked or referenced in the head of the initial page. If those assets change, either more or added or existing ones have a new URL, the page will do a full reload instead of going through Turbolinks. This ensures that all Turbolinks sessions will always be running off your latest JavaScript and CSS.
You can track certain assets, like application.js and application.css, that you want to ensure are always of the latest version inside a Turbolinks session. This is done by marking those asset links with data-turbolinks-track, like so:

When this happens, you'll technically be requesting the same page twice. Once through Turbolinks to detect that the assets changed, and then again when we do a full redirect to that page.
<link href="/assets/application.css?9bd64a86adb3cd9ab3b16e9dca67a33a.css" media="screen" rel="stylesheet" type="text/css" data-turbolinks-track>

If those assets change URLs (embed an md5 stamp to ensure this), the page will do a full reload instead of going through Turbolinks. This ensures that all Turbolinks sessions will always be running off your latest JavaScript and CSS.

A common case where this could happen is when a Javascript snippet (like the one from [Google Analytics](https://developers.google.com/analytics/devguides/collection/gajs/)) adds a script tag to the head dynamically. Make sure to load Turbolinks __before__ such snippets. Turbolinks will then only remember the assets which are present when it's loaded and ignore scripts which are added later.
When this happens, you'll technically be requesting the same page twice. Once through Turbolinks to detect that the assets changed, and then again when we do a full redirect to that page.


Evaluating script tags
Expand Down
2 changes: 1 addition & 1 deletion turbolinks.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'turbolinks'
s.version = '0.5.2'
s.version = '0.6.0'
s.author = 'David Heinemeier Hansson'
s.email = '[email protected]'
s.summary = 'Turbolinks makes following links in your web application faster (use with Rails Asset Pipeline)'
Expand Down

0 comments on commit f0213d4

Please sign in to comment.