Permalink
Browse files

Fix local caching issue

Make the browser not cache images if you are running locally.
  • Loading branch information...
Koen Bok
Koen Bok committed May 29, 2013
1 parent dcd4faa commit 2d590001660d14470985d4f56167569dd214f17b
Showing with 23 additions and 3 deletions.
  1. +12 −3 build/framer.js
  2. +4 −0 src/utils.coffee
  3. +7 −0 src/views/imageview.coffee
View
@@ -1,7 +1,7 @@
// Framer 2.0-13-g150f969 (c) 2013 Koen Bok
// Framer 2.0-14-gdcd4faa (c) 2013 Koen Bok
// https://github.com/koenbok/Framer
window.FramerVersion = "2.0-13-g150f969";
window.FramerVersion = "2.0-14-gdcd4faa";
(function(){var require = function (file, cwd) {
@@ -635,6 +635,10 @@ require.define("/src/utils.coffee",function(require,module,exports,__dirname,__f
return /iphone|ipod|android|ie|blackberry|fennec/.test(navigator.userAgent.toLowerCase());
};
exports.isLocal = function() {
return window.location.href.slice(0, 7) === "file://";
};
exports.devicePixelRatio = function() {
return window.devicePixelRatio;
};
@@ -4561,10 +4565,12 @@ require.define("/src/views/scrollview.coffee",function(require,module,exports,__
});
require.define("/src/views/imageview.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
var View, config,
var View, config, uitis,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
uitis = require("../utils");
View = require("./view").View;
config = require("../config").config;
@@ -4594,6 +4600,9 @@ require.define("/src/views/imageview.coffee",function(require,module,exports,__d
return this.emit("load", loader);
}
this._image = config.baseUrl + value;
if (utils.isLocal()) {
this._image += "?nocache=" + (Date.now());
}
if ((_ref = this.events) != null ? _ref.hasOwnProperty("load" || ((_ref1 = this.events) != null ? _ref1.hasOwnProperty("error") : void 0)) : void 0) {
loader = new Image();
loader.name = this.image;
View
@@ -117,10 +117,14 @@ exports.isMobile = ->
(/iphone|ipod|android|ie|blackberry|fennec/).test \
navigator.userAgent.toLowerCase()
exports.isLocal = ->
window.location.href[0..6] == "file://"
exports.devicePixelRatio = ->
window.devicePixelRatio
######################################################
# DOM FUNCTIONS
@@ -1,3 +1,5 @@
uitis = require "../utils"
{View} = require "./view"
{config} = require "../config"
@@ -24,8 +26,13 @@ class exports.ImageView extends View
if @_image is value
return @emit "load", loader
# Add the optional base url from the config
@_image = config.baseUrl + value
# If the file is local, we want to avoid caching
if utils.isLocal()
@_image += "?nocache=#{Date.now()}"
# As an optimization, we will only use a loader
# if something is explicitly listening to the load event

0 comments on commit 2d59000

Please sign in to comment.