From 41ca47edfc791f64cac06246120cd450bdebff4d Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Thu, 13 Dec 2012 09:47:51 -0500 Subject: [PATCH] Add flag to turn template caching on/off (default to off) --- cms/static/js/base.js | 4 ++++ cms/static/js/template_loader.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 47835fda66..eefc8c3c37 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -15,6 +15,10 @@ $(document).ready(function() { // pipelining (note, this doesn't happen on local runtimes). So if we set it on window, when we can access it from other // scopes (namely the course-info tab) window.$modalCover = $modalCover; + + // Control whether template caching in local memory occurs (see template_loader.js). Caching screws up development but may + // be a good optimization in production (it works fairly well) + window.cachetemplates = false; $body.append($modalCover); $newComponentItem = $('.new-component-item'); diff --git a/cms/static/js/template_loader.js b/cms/static/js/template_loader.js index 2e900814b0..03104566ec 100644 --- a/cms/static/js/template_loader.js +++ b/cms/static/js/template_loader.js @@ -35,7 +35,8 @@ localStorageAvailable: function() { try { - return 'localStorage' in window && window['localStorage'] !== null; + // window.cachetemplates is global set in base.js to turn caching on/off + return window.cachetemplates && 'localStorage' in window && window['localStorage'] !== null; } catch (e) { return false; }