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

This commit is contained in:
seo
2026-07-25 19:33:34 +09:00
parent 10c00b3e57
commit 3aff2748e8
4 changed files with 58 additions and 15 deletions
+21 -7
View File
@@ -14,6 +14,20 @@ if (!headers_sent()) {
$csrf = csrf_token();
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);
}
if (isset($_GET['logout'])) {
clear_remember_token();
clear_common_admin_auth_cookie_if_available();
@@ -78,11 +92,11 @@ $loggedIn = signed_in();
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap" rel="stylesheet">
<link rel="icon" href="/assets/favicon.svg" type="image/svg+xml">
<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.json">
<script src="/assets/asset-reload.js?v=20260721_nocache1" data-service="control" defer></script>
<link rel="icon" href="<?= e(asset_url('/assets/favicon.svg')) ?>" type="image/svg+xml">
<link rel="icon" href="<?= e(asset_url('/assets/icon-192.png')) ?>" type="image/png" sizes="192x192">
<link rel="apple-touch-icon" href="<?= e(asset_url('/assets/apple-touch-icon.png')) ?>">
<link rel="manifest" href="<?= e(asset_url('/manifest.json')) ?>">
<script src="<?= e(asset_url('/assets/asset-reload.js')) ?>" data-service="control" defer></script>
<meta name="theme-color" content="#0f1115">
<script>
try {
@@ -372,8 +386,8 @@ html[data-theme="light"] .details-panel{background:#edf3fa;border-color:#b8c7da}
</div>
</div>
</div>
<script src="/assets/app.js?v=20260723_touch_display3"></script>
<script src="/assets/wakelock.js?v=20260607_prefs1"></script>
<script src="<?= e(asset_url('/assets/app.js')) ?>"></script>
<script src="<?= e(asset_url('/assets/wakelock.js')) ?>"></script>
<?php endif; ?>
</body>
</html>