에셋 리로드 파일별 캐시 검증 보강

This commit is contained in:
seo
2026-07-25 19:45:14 +09:00
parent b7534d8824
commit 520a5f679d
4 changed files with 55 additions and 15 deletions
+20 -6
View File
@@ -5,6 +5,20 @@ header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');
function asset_url(string $path): string
{
$fullPath = __DIR__ . '/' . ltrim($path, '/');
$version = 'dev';
if (is_file($fullPath)) {
$mtime = filemtime($fullPath) ?: time();
$hash = is_readable($fullPath) ? substr(hash_file('sha256', $fullPath) ?: '', 0, 10) : '';
$version = $mtime . ($hash !== '' ? '-' . $hash : '');
}
return $path . '?v=' . rawurlencode($version);
}
$nginxFiles = [
'/etc/nginx/nginx.conf',
'/etc/nginx/sites-enabled',
@@ -317,12 +331,12 @@ ksort($items, SORT_NATURAL);
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Seoul">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="icon" href="assets/favicon.svg" type="image/svg+xml">
<link rel="icon" href="assets/icon-32.png" type="image/png" sizes="32x32">
<link rel="icon" href="assets/icon-192.png" type="image/png" sizes="192x192">
<link rel="apple-touch-icon" href="assets/apple-touch-icon.png">
<link rel="manifest" href="manifest.webmanifest">
<script src="assets/asset-reload.js?v=20260721_nocache1" data-service="seoul" defer></script>
<link rel="icon" href="<?= htmlspecialchars(asset_url('assets/favicon.svg'), ENT_QUOTES, 'UTF-8') ?>" type="image/svg+xml">
<link rel="icon" href="<?= htmlspecialchars(asset_url('assets/icon-32.png'), ENT_QUOTES, 'UTF-8') ?>" type="image/png" sizes="32x32">
<link rel="icon" href="<?= htmlspecialchars(asset_url('assets/icon-192.png'), ENT_QUOTES, 'UTF-8') ?>" type="image/png" sizes="192x192">
<link rel="apple-touch-icon" href="<?= htmlspecialchars(asset_url('assets/apple-touch-icon.png'), ENT_QUOTES, 'UTF-8') ?>">
<link rel="manifest" href="<?= htmlspecialchars(asset_url('manifest.webmanifest'), ENT_QUOTES, 'UTF-8') ?>">
<script src="<?= htmlspecialchars(asset_url('assets/asset-reload.js'), ENT_QUOTES, 'UTF-8') ?>" data-service="seoul" defer></script>
<script src="https://chaegeon.com/log/bancheck.min.js?_=<?php echo time(); ?>"></script>
<style>
* {