perf & ux : cache getAll, fingerprint assets, Last-Modified, 404 log, row-click bulk (v1.6.19)
- getAll() : cache fichier articles_list.json, invalidé à chaque écriture (#16) - layout.php : fingerprinting ?v=<hash> sur CSS/JS pour invalidation navigateur (#18) - case 'view' : Last-Modified + 304 Not Modified pour les articles publiés (#18) - case 'not_found' : logging JSON des 404 dans _logs/not_found.jsonl (#52) - case 'view' : echo nu → templates/404.php pour brouillons/privés (#52) - admin.js : clic sur ligne tableau → toggle bulk-check (#86) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+22
-1
@@ -30,6 +30,14 @@ class ArticleManager
|
||||
|
||||
private function loadAll(): array
|
||||
{
|
||||
$cachePath = $this->allListCachePath();
|
||||
if (file_exists($cachePath)) {
|
||||
$cached = json_decode((string)file_get_contents($cachePath), true);
|
||||
if (is_array($cached) && $cached !== []) {
|
||||
return $cached;
|
||||
}
|
||||
}
|
||||
|
||||
$articles = [];
|
||||
if (!is_dir($this->dataDir)) {
|
||||
return $articles;
|
||||
@@ -66,6 +74,12 @@ class ArticleManager
|
||||
}
|
||||
}
|
||||
|
||||
$cacheDir = dirname($cachePath);
|
||||
if (!is_dir($cacheDir)) {
|
||||
@mkdir($cacheDir, 0755, true);
|
||||
}
|
||||
@file_put_contents($cachePath, json_encode($articles, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
@@ -849,6 +863,7 @@ class ArticleManager
|
||||
$this->allCache = null;
|
||||
@unlink($this->articleCachePath($uuid));
|
||||
@unlink($this->slugIndexPath());
|
||||
@unlink($this->allListCachePath());
|
||||
$this->removeDir($dir);
|
||||
}
|
||||
if (is_dir($dir)) {
|
||||
@@ -879,6 +894,11 @@ class ArticleManager
|
||||
return $this->dataDir . '/_cache/slug_index.json';
|
||||
}
|
||||
|
||||
private function allListCachePath(): string
|
||||
{
|
||||
return $this->dataDir . '/_cache/articles_list.json';
|
||||
}
|
||||
|
||||
private function buildSlugIndex(): void
|
||||
{
|
||||
$cacheDir = $this->dataDir . '/_cache';
|
||||
@@ -1343,9 +1363,10 @@ class ArticleManager
|
||||
$this->searchIndexCache = null;
|
||||
$uuid = $meta['uuid'] ?? basename($dir);
|
||||
|
||||
// Invalider le cache article et le slug index
|
||||
// Invalider les caches article, liste et slug index
|
||||
@unlink($this->articleCachePath($uuid));
|
||||
@unlink($this->slugIndexPath());
|
||||
@unlink($this->allListCachePath());
|
||||
|
||||
file_put_contents(
|
||||
$dir . '/meta.json',
|
||||
|
||||
Reference in New Issue
Block a user