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

This commit is contained in:
seo
2026-07-25 19:45:14 +09:00
parent 07836bad10
commit 08e705c1f7
7 changed files with 79 additions and 35 deletions
+22 -7
View File
@@ -1,11 +1,26 @@
<?php
function h($value): string
{
return htmlspecialchars((string)($value ?? ''), ENT_QUOTES, 'UTF-8');
}
function won($value): string
function h($value): string
{
return htmlspecialchars((string)($value ?? ''), ENT_QUOTES, 'UTF-8');
}
function asset_url(string $path): string
{
$publicRoot = realpath(__DIR__ . '/../../public');
$fullPath = $publicRoot ? $publicRoot . '/' . ltrim($path, '/') : '';
$version = 'dev';
if ($fullPath !== '' && 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);
}
function won($value): string
{
return number_format((float)$value, 0) . '원';
}
@@ -95,4 +110,4 @@ function get_flash_message(): ?array
$flash = $_SESSION['flash_message'];
unset($_SESSION['flash_message']);
return $flash;
}
}