Explorar o código

Évite les problèmes de cache des resources CSS et JS statiques

Ajoute une date automatique aux CSS et JS. Ne devrait pas entraver la
bonne mise en cache grâce aux entêtes HTTP dont `Cache-Control: public`
Alexandre Alapetite %!s(int64=12) %!d(string=hai) anos
pai
achega
a5bc7d20d4
Modificáronse 2 ficheiros con 7 adicións e 7 borrados
  1. 5 5
      app/App_FrontController.php
  2. 2 2
      app/controllers/indexController.php

+ 5 - 5
app/App_FrontController.php

@@ -54,18 +54,18 @@ class App_FrontController extends FrontController {
 		$theme = RSSThemes::get_infos($this->conf->theme());
 		if ($theme) {
 			foreach($theme["files"] as $file) {
-				View::appendStyle (Url::display ('/themes/' . $theme['path'] . '/' . $file));
+				View::appendStyle (Url::display ('/themes/' . $theme['path'] . '/' . $file . '?' . filemtime(PUBLIC_PATH . '/themes/' . $theme['path'] . '/' . $file)));
 			}
 		}
-		View::appendStyle (Url::display ('/themes/printer/style.css'), 'print');
+		View::appendStyle (Url::display ('/themes/printer/style.css?' . filemtime(PUBLIC_PATH . '/themes/printer/style.css')), 'print');
 		if (login_is_conf ($this->conf)) {
 			View::appendScript ('https://login.persona.org/include.js');
 		}
-		View::appendScript (Url::display ('/scripts/jquery.min.js'));
+		View::appendScript (Url::display ('/scripts/jquery.min.js?' . filemtime(PUBLIC_PATH . '/scripts/jquery.min.js')));
 		if ($this->conf->lazyload () === 'yes' && ($this->conf->displayPosts () === 'yes' || Request::param ('output') === 'reader')) {
-			View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js'));
+			View::appendScript (Url::display ('/scripts/jquery.lazyload.min.js?' . filemtime(PUBLIC_PATH . '/scripts/jquery.lazyload.min.js')));
 		}
-		View::appendScript (Url::display ('/scripts/main.js'));
+		View::appendScript (Url::display ('/scripts/main.js?' . filemtime(PUBLIC_PATH . '/scripts/main.js')));
 	}
 
 	private function loadNotifications () {

+ 2 - 2
app/controllers/indexController.php

@@ -46,10 +46,10 @@ class indexController extends ActionController {
 				Request::_param ('output', $output);
 			}
 
-			View::appendScript (Url::display ('/scripts/shortcut.js'));
+			View::appendScript (Url::display ('/scripts/shortcut.js?' . filemtime(PUBLIC_PATH . '/scripts/shortcut.js')));
 
 			if ($output == 'global') {
-				View::appendScript (Url::display ('/scripts/global_view.js'));
+				View::appendScript (Url::display ('/scripts/global_view.js?' . filemtime(PUBLIC_PATH . '/scripts/global_view.js')));
 			}
 		}