/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
- * Copyright (c) 2001-2012 *
+ * Copyright (c) 2001-2014 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
/// http://doc.spip.org/@cache_valide
function cache_valide(&$page, $date) {
+ // Apparition d'un nouvel article post-date ?
+ if ($GLOBALS['meta']['post_dates'] == 'non'
+ AND isset($GLOBALS['meta']['date_prochain_postdate'])
+ AND time() > $GLOBALS['meta']['date_prochain_postdate']) {
+ spip_log('Un article post-date invalide le cache');
+ include_spip('inc/rubriques');
+ calculer_prochain_postdate(true);
+ }
+
if (defined('_VAR_NOCACHE') AND _VAR_NOCACHE) return -1;
if (isset($GLOBALS['meta']['cache_inhib']) AND $_SERVER['REQUEST_TIME']<$GLOBALS['meta']['cache_inhib']) return -1;
if (defined('_NO_CACHE')) return (_NO_CACHE==0 AND !isset($page['texte']))?1:_NO_CACHE;
- if (!$page OR !isset($page['texte']) OR !isset($page['entetes']['X-Spip-Cache'])) return 1;
+
+ // pas de cache ? on le met a jour, sauf pour les bots (on leur calcule la page sans mise en cache)
+ if (!$page OR !isset($page['texte']) OR !isset($page['entetes']['X-Spip-Cache'])) return _IS_BOT?-1:1;
// #CACHE{n,statique} => on n'invalide pas avec derniere_modif
// cf. ecrire/public/balises.php, balise_CACHE_dist()
AND $date < $GLOBALS['meta']['derniere_modif'])
return 1;
- // Apparition d'un nouvel article post-date ?
- if ($GLOBALS['meta']['post_dates'] == 'non'
- AND isset($GLOBALS['meta']['date_prochain_postdate'])
- AND time() > $GLOBALS['meta']['date_prochain_postdate']) {
- spip_log('Un article post-date invalide le cache');
- include_spip('inc/rubriques');
- ecrire_meta('derniere_modif', time());
- calculer_prochain_postdate();
- return 1;
- }
-
}
// Sinon comparer l'age du fichier a sa duree de cache
$duree = intval($page['entetes']['X-Spip-Cache']);
if ($duree == 0) #CACHE{0}
return -1;
- else if ($date + $duree < time())
+ // sauf pour les bots, qui utilisent toujours le cache
+ else if (!_IS_BOT AND $date + $duree < time())
return 1;
else
return 0;