diff --git a/.htaccess b/.htaccess index 5848627..d984b5e 100644 --- a/.htaccess +++ b/.htaccess @@ -57,7 +57,6 @@ AddDefaultCharset UTF-8 ExpiresActive On - ExpiresDefault "access plus 1 hour" ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType image/webp "access plus 1 year" diff --git a/index.php b/index.php index 7d9f697..e35943b 100644 --- a/index.php +++ b/index.php @@ -12,12 +12,24 @@ } header_remove('X-Powered-By'); +header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); +header('Pragma: no-cache'); +header('Expires: 0'); function escape(string $value): string { return htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } +function assetUrl(string $path): string +{ + $relativePath = ltrim($path, '/'); + $absolutePath = __DIR__ . '/' . $relativePath; + $version = is_file($absolutePath) ? (string) filemtime($absolutePath) : '1'; + + return escape('/' . $relativePath . '?v=' . rawurlencode($version)); +} + function isCurrentPage(string $page): bool { global $currentPage; diff --git a/views/partials/footer.php b/views/partials/footer.php index a102893..d68dd85 100644 --- a/views/partials/footer.php +++ b/views/partials/footer.php @@ -53,6 +53,6 @@
- + diff --git a/views/partials/head.php b/views/partials/head.php index fd74343..29e1e2a 100644 --- a/views/partials/head.php +++ b/views/partials/head.php @@ -15,8 +15,8 @@ - - + + <?= escape($pageTitle) ?> — <?= SITE_NAME ?>