From 0973724db51c41f7564127f111e86114378d6013 Mon Sep 17 00:00:00 2001 From: Calvin Correli Date: Thu, 19 Mar 2015 18:42:17 -0400 Subject: [PATCH] Allow pages to say they don't want to be cached Add a data-no-turbolinks-cache attribute to any tag, and the entire page won't be cached. This is useful in situations where the page contains elements such as video tags that need to be rendered using video.js, which aren't compatible with being stored in the cache. You could use data-no-turbolink to prevent links on the page from using turbolinks, but that's not really what we're after. --- lib/assets/javascripts/turbolinks.js.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/assets/javascripts/turbolinks.js.coffee b/lib/assets/javascripts/turbolinks.js.coffee index 14c0e774..d912bb15 100644 --- a/lib/assets/javascripts/turbolinks.js.coffee +++ b/lib/assets/javascripts/turbolinks.js.coffee @@ -97,6 +97,8 @@ fetchHistory = (cachedPage) -> triggerEvent EVENTS.RESTORE cacheCurrentPage = -> + return if document.querySelector('[data-no-turbolinks-cache]')? + currentStateUrl = new ComponentUrl currentState.url pageCache[currentStateUrl.absolute] =