diff options
| author | 2013-11-03 20:28:52 +0100 | |
|---|---|---|
| committer | 2013-11-04 23:32:22 +0100 | |
| commit | adc9a958afa5fb9f6f2dab4ae8abac1f932a7db4 (patch) | |
| tree | 4a739d492582f3ba95d66d6f8072f6ecbcc1e654 /public | |
| parent | 231516f5238b6023001bed548569077c61411a4e (diff) | |
Préchargement et requêtes conditionnelles HTTP/1.1
Grosse amélioration des performances en utilisant le cache HTTP :
- Implémentation de HTTP/1.1, c.a.d. If-Modified-Since, If-None-Match,
If-Unmodified-Since, If-Match... avec la librairie
http://alexandre.alapetite.fr/doc-alex/php-http-304/
- Support de HEAD (HTTP /1.0).
- Préchargement de la page suivante (avec link next prefetch) dans le
cas de pagination.
- Et nouvelle possibilité de navigation pour les navigateurs qui
supportent "next".
- La date de dernier changement est pour l'instant primitive et
correspond au dernier changement de la session PHP ou
Configuration.array.php ou application.log ou touch.txt.
- touch.txt est modifié a chaque requête UPDATE ou INSERT ou DELETE.
Diffstat (limited to 'public')
| -rwxr-xr-x | public/index.php | 10 | ||||
| -rw-r--r-- | public/scripts/main.js | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/public/index.php b/public/index.php index 64aabb609..daf65c54a 100755 --- a/public/index.php +++ b/public/index.php @@ -28,6 +28,16 @@ define ('CACHE_PATH', realpath (PUBLIC_PATH . '/../cache')); if (file_exists (PUBLIC_PATH . '/install.php')) { include ('install.php'); } else { + session_cache_limiter(''); + require (LIB_PATH . '/http-conditional.php'); + $dateLastModification = max(filemtime(filemtime(PUBLIC_PATH . '/data/touch.txt'), + PUBLIC_PATH . '/data/Configuration.array.php'), + filemtime(LOG_PATH . '/application.log'), + time() - 3600); + if (httpConditional($dateLastModification, 0, 0, false, false, true)) { + exit(); //No need to send anything + } + set_include_path (get_include_path () . PATH_SEPARATOR . LIB_PATH diff --git a/public/scripts/main.js b/public/scripts/main.js index 92259696f..19e2905cc 100644 --- a/public/scripts/main.js +++ b/public/scripts/main.js @@ -490,6 +490,11 @@ function init_load_more() { } url_load_more = $next_link.attr("href"); + var $prefetch = $('#prefetch'); + if ($prefetch.attr('href') !== url_load_more) { + $.ajax({url: url_load_more, ifModified: true }); //TODO: Try to find a less agressive solution + $prefetch.attr('href', url_load_more); + } $next_link.click(function () { load_more_posts(); |
