Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ AddDefaultCharset UTF-8

<IfModule mod_expires.c>
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"
Expand Down
12 changes: 12 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion views/partials/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
</footer>

<div class="toast" role="status" aria-live="polite" aria-atomic="true" data-toast></div>
<script src="/assets/js/main.js" defer></script>
<script src="<?= assetUrl('assets/js/main.js') ?>" defer></script>
</body>
</html>
4 changes: 2 additions & 2 deletions views/partials/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<meta property="og:image" content="<?= SITE_URL ?>/assets/images/profile-640.webp">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="<?= SITE_URL . escape($path) ?>">
<link rel="icon" href="/assets/images/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="/assets/css/style.css">
<link rel="icon" href="<?= assetUrl('assets/images/favicon.svg') ?>" type="image/svg+xml">
<link rel="stylesheet" href="<?= assetUrl('assets/css/style.css') ?>">
<title><?= escape($pageTitle) ?> — <?= SITE_NAME ?></title>
</head>
<body>
Expand Down