From f2dbe40a512791a521072c7d74f7533dcbf2ad8e Mon Sep 17 00:00:00 2001 From: Maros Hluska Date: Wed, 25 Nov 2015 17:22:47 -0500 Subject: [PATCH] Add expire flag for transition cache --- lib/assets/javascripts/turbolinks.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/assets/javascripts/turbolinks.coffee b/lib/assets/javascripts/turbolinks.coffee index 85d68db1..ad95b4a8 100644 --- a/lib/assets/javascripts/turbolinks.coffee +++ b/lib/assets/javascripts/turbolinks.coffee @@ -1,6 +1,7 @@ pageCache = {} cacheSize = 10 transitionCacheEnabled = false +transitionCacheExpire = true requestCachingEnabled = true progressBar = null progressBarDelay = 400 @@ -52,14 +53,17 @@ fetch = (url, options = {}) -> else options.scroll ?= false if isPartialReplacement(options) and !url.hash - fetchReplacement url, options + if transitionCacheExpire or not cachedPage? + fetchReplacement url, options transitionCacheFor = (url) -> return if url is currentState.url cachedPage = pageCache[url] cachedPage if cachedPage and !cachedPage.transitionCacheDisabled -enableTransitionCache = (enable = true) -> +enableTransitionCache = (enable = true, options = {}) -> + options.expire ?= true + transitionCacheExpire = options.expire transitionCacheEnabled = enable disableRequestCaching = (disable = true) ->