Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Add expire flag for transition cache #639

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/assets/javascripts/turbolinks.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pageCache = {}
cacheSize = 10
transitionCacheEnabled = false
transitionCacheExpire = true
requestCachingEnabled = true
progressBar = null
progressBarDelay = 400
Expand Down Expand Up @@ -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) ->
Expand Down