Permalink
Browse files

Added a mechanism to force clients to flush their JS cache

  • Loading branch information...
1 parent f3e43d9 commit a987d26d81b75bc132b8a0bac41ba8c51a76b8a6 @TimothyJones TimothyJones committed Mar 12, 2015
Showing with 7 additions and 2 deletions.
  1. +4 −1 doc/javascript.txt
  2. +3 −1 lib/html.php
View
@@ -16,6 +16,9 @@ JavaScript is used in webDiplomacy for three things mainly:
- The FAQ and "New thread" button in the forum
- Allowing the map image history of a game to be scrolled through
+If you change the JS code, then you can increment $jsVersion in lib/html.php to force clients
+to reload their javascript.
+
Prototype framework
-------------------
The Prototype framework is used to make this functionality possible as
@@ -150,4 +153,4 @@ ajax.php
providing debugging info.
orders/form.js interacts with ajax.php to submit orders, using JSON token data to authenticate
as a certain country with control over certain orders without having to authenticate the user
- first.
+ first.
View
@@ -887,6 +887,8 @@ public static function likeCount($likeCount) {
static private function footerScripts() {
global $User, $Locale;
+ $jsVersion = 1; // increment this to force clients to reload their JS files
+
$buf = '';
// onlineUsers, for the online icons
@@ -940,7 +942,7 @@ static private function footerScripts() {
// Don't localize all the footer includes here, as some of them may be dynamically generated
foreach( array_merge($footerIncludes,self::$footerIncludes) as $includeJS ) // Add on the dynamically added includes
- $buf .= '<script type="text/javascript" src="'.STATICSRV.JSDIR.'/'.$includeJS.'"></script>';
+ $buf .= '<script type="text/javascript" src="'.STATICSRV.JSDIR.'/'.$includeJS.'?ver='.$jsVersion.'"></script>';
// Utility (error detection, message protection), HTML post-processing,
// time handling functions. Only logged-in users need to run these

0 comments on commit a987d26

Please sign in to comment.