Skip to content
Permalink
Browse files

Fix for image cache

Cache is now disabled only for local images (server and file urls). You can optionally force using the cache by using layer. _alwaysUseImageCache.
  • Loading branch information
koenbok committed Jul 17, 2015
1 parent 5c47bd5 commit b34eca1e8137716e36aacb4e5d96b07e5b878ee2
Showing with 8 additions and 12 deletions.
  1. +1 −1 framer/Components/DeviceComponent.coffee
  2. +7 −11 framer/Layer.coffee
@@ -261,7 +261,7 @@ class exports.DeviceComponent extends BaseClass
else if not @_deviceImageUrl(@_deviceImageName())
@phone.image = ""
else
@phone._cacheImage = true
@phone._alwaysUseImageCache = true
@phone.image = @_deviceImageUrl(@_deviceImageName())
@phone.width = @_device.deviceImageWidth
@phone.height = @_device.deviceImageHeight
@@ -53,7 +53,7 @@ class exports.Layer extends BaseClass
# Special power setting for 2d rendering path. Only enable this
# if you know what you are doing. See LayerStyle for more info.
@_prefer2d = false
@_cacheImage = true
@_alwaysUseImageCache = false

# We have to create the element before we set the defaults
@_createElement()
@@ -547,18 +547,12 @@ class exports.Layer extends BaseClass
# imageUrl = Config.baseUrl + imageUrl


# See if we need to cache the image
shoudUseImageCache = true
print imageUrl
print "@_cacheImage", @_cacheImage
print "Utils.isLocalAssetUrl(imageUrl)", Utils.isLocalAssetUrl(imageUrl)

# We can always disable the cache with this property
if @_cacheImage is false
shoudUseImageCache = false

# If this is a file url, we don't use any cache
else if Utils.isLocalAssetUrl(imageUrl)
shoudUseImageCache = false

if shoudUseImageCache is false
if @_alwaysUseImageCache is false and Utils.isLocalAssetUrl(imageUrl)
imageUrl += "?nocache=#{NoCacheDateKey}"

# As an optimization, we will only use a loader
@@ -769,6 +763,8 @@ class exports.Layer extends BaseClass
exportable: false
get: ->
@_draggable ?= new LayerDraggable(@)
set: (value) ->
@draggable.enabled = value if _.isBoolean(value)

# anchor: ->
# if not @_anchor

0 comments on commit b34eca1

Please sign in to comment.
You can’t perform that action at this time.