From 7730cba1491350ae626a159cf39182df8db8d621 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 10 Sep 2014 11:55:44 -0400 Subject: [PATCH] [SIGNED-OFF] Bug 12904 - Force browser to load new javascript files after upgrade Content-Type: text/plain; charset="utf-8" A common issue with Koha seems to be that the web browsers continue to use cached js files after an upgrade. If we append the version as a parameter, we can force the browser to update the javascript files. Test Plan: 1) Apply this patch 2) Note that all javascript continues to function properly Signed-off-by: Owen Leonard More complete test plan to confirm that caching is working correctly: 1) Apply this patch on a new branch based on master. 2) In a separate branch check out a previous version of Koha and go through the installation process on an empty database. 3) After logging into Koha, turn on Firebug's Net panel (or Chrome's Network panel) and turn on the filter for JavaScript files. 4) Clear the browser cache and navigate to a page, for instance Circulation. In Firebug the Net panel should show a status of "200 OK" for all files, indicating that the file was downloaded, not loaded from the cache. In Chrome the "size" column will show a file size if the file was downloaded. 5) Navigate to another page and confirm that scripts are being loaded from the cache: Scripts like jquery.js and jquery-ui.js which are loaded on every page should have a status in the Firebug Net panel of "304 Not Modified." In Chrome the "size" columns should show "from cache." 6) Check out the branch you created for testing this patch. 7) In order to preserve the state of your browser cache for accurate testing, open a different browser from the one you were previously testing with, load Koha, and run through the database update. 8) Return to your original testing browser and navigate to another Koha page. Firebug's Net panel should show that script files are now being downloaded with a "koha_version" query string. These files should have a status of "200 OK" indicating that they are being downloaded, not loaded from the cache. 9) Navigate to another page and conifrm that the new versions of the scripts are being loaded from the cache. To confirm that all affected JavaScripts links are working correctly, test these pages by checking the Firebug Net panel for errors: - Administration -> Currencies and exchange rates (jquery.dataTables.colvis.js) - Tools -> Stage MARC records for import (ajaxfileupload.js) or another page which performs a file upload. - Catalog -> Detail page -> MARC Preview (greybox JS) - Help -> Any help page - Any page which loads DataTables (Circulation in the staff client, for instance, and a title's detail page in the OPAC) - Bonus points if you check the various conditional JS includes controlled by the many OPAC feature preferences --- .../prog/en/includes/columns_settings.inc | 4 +- .../intranet-tmpl/prog/en/includes/datatables.inc | 6 ++- .../prog/en/includes/doc-head-close.inc | 22 ++++++----- .../intranet-tmpl/prog/en/includes/file-upload.inc | 4 +- .../intranet-tmpl/prog/en/includes/greybox.inc | 8 ++-- .../intranet-tmpl/prog/en/includes/help-top.inc | 18 +++++---- .../opac-tmpl/bootstrap/en/includes/datatables.inc | 6 ++- .../bootstrap/en/includes/doc-head-close.inc | 8 ++-- .../bootstrap/en/includes/opac-bottom.inc | 40 ++++++++++---------- 9 files changed, 67 insertions(+), 49 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc index 87d9da6..0a3dded 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -1,7 +1,9 @@ +[% USE Koha %] +[% SET KOHA_VERSION = Koha.Preference('Version') %] [% USE ColumnsSettings %] - + +[% USE Koha %] +[% SET KOHA_VERSION = Koha.Preference('Version') %] + - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index f6269de..fed1473 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -1,3 +1,5 @@ +[% USE Koha %] +[% SET KOHA_VERSION = Koha.Preference('Version') %] @@ -8,20 +10,20 @@ [% END %] [% IF ( IntranetUserCSS ) %][% END %] - - - - - - - + + + + + + + [% IF ( login ) %] [% END %] - + [% INCLUDE 'validator-strings.inc' %] [% IF ( intranetuserjs ) %] - + [% END %] [% IF LocalCoverImages %] - + + - - - + + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc index 5dcbe27..cc3487b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc @@ -1,3 +1,5 @@ +[% USE Koha %] +[% SET KOHA_VERSION = Koha.Preference('Version') %] [% INCLUDE 'doc-head-open.inc' %] Online Help @@ -8,16 +10,16 @@ [% IF ( bidi ) %] [% END %] - - - + + + - - - - + + + + - + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc index d3075c9..3379bab 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/datatables.inc @@ -1,4 +1,6 @@ - +[% USE Koha %] +[% SET KOHA_VERSION = Koha.Preference('Version') %] + - \ No newline at end of file + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc index c3e2d83..6d4d2b4 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/doc-head-close.inc @@ -1,3 +1,5 @@ +[% USE Koha %] +[% SET KOHA_VERSION = Koha.Preference('Version') %] @@ -41,11 +43,11 @@ [% IF ( OPACUserCSS ) %][% END %] [% PROCESS cssinclude %] - + - + diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index 4128061..4d9590d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -1,3 +1,5 @@ +[% USE Koha %] +[% SET KOHA_VERSION = Koha.Preference('Version') %] [% UNLESS ( is_popup ) %] [% IF ( opaccredits ) %]
@@ -75,24 +77,24 @@ - - + + - - + + [% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %] @@ -100,11 +102,11 @@ $.widget.bridge('uitooltip', $.ui.tooltip); var NO_AMAZON_IMAGE = _("No cover image available"); //]]> - + [% END %] -[% IF Koha.Preference( 'opacbookbag' ) == 1 %] @@ -154,15 +156,15 @@ $.widget.bridge('uitooltip', $.ui.tooltip); //]]> [% IF Koha.Preference( 'opacbookbag' ) == 1 %] - + [% ELSIF ( Koha.Preference( 'virtualshelves' ) == 1 ) %] - + [% ELSE %] [% END %] -[% IF Koha.Preference( 'opacuserlogin' ) == 1 %][% IF Koha.Preference( 'TagsEnabled' ) == 1 %][% END %][% ELSE %][% END %] +[% IF Koha.Preference( 'opacuserlogin' ) == 1 %][% IF Koha.Preference( 'TagsEnabled' ) == 1 %][% END %][% ELSE %][% END %] [% IF ( GoogleJackets ) %] - + [% END %] [% IF OpenLibraryCovers %] - + + + - + [% END %] [% IF persona %] - +