feat: キャッシュ完全無効化・常時最新取得対応(IIS web.config / Caddyfile / HTML metaタグ / JSキャッシュバスター)
This commit is contained in:
1 parent
b20fdb934d
commit
d5a829bcd7
143 files changed
+478
-2
No files matched your search
@@ -315,8 +315,39 @@ function initMacroCopy() {
|
||||
});
|
||||
}
|
||||
|
||||
// キャッシュ完全無効化ポリシーの適用(常に最新データを取得)
|
||||
function applyNoCachePolicy() {
|
||||
// 1. metaタグによるキャッシュ無効化の動的保証
|
||||
const metaDirectives = [
|
||||
{ httpEquiv: 'Cache-Control', content: 'no-cache, no-store, must-revalidate' },
|
||||
{ httpEquiv: 'Pragma', content: 'no-cache' },
|
||||
{ httpEquiv: 'Expires', content: '0' }
|
||||
];
|
||||
metaDirectives.forEach(dir => {
|
||||
if (!document.querySelector('meta[http-equiv="' + dir.httpEquiv + '"]')) {
|
||||
const meta = document.createElement('meta');
|
||||
meta.httpEquiv = dir.httpEquiv;
|
||||
meta.content = dir.content;
|
||||
document.head.appendChild(meta);
|
||||
}
|
||||
});
|
||||
|
||||
// 2. iframe読み込み時のキャッシュバスター付与
|
||||
const cacheBuster = Date.now();
|
||||
document.querySelectorAll('iframe.wiki-header-frame, iframe.wiki-sidebar-frame').forEach(frame => {
|
||||
const originalSrc = frame.getAttribute('src');
|
||||
if (originalSrc && !originalSrc.includes('_t=')) {
|
||||
const separator = originalSrc.includes('?') ? '&' : '?';
|
||||
frame.src = originalSrc + separator + '_t=' + cacheBuster;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 共通初期化処理
|
||||
function initWikiCommon() {
|
||||
// キャッシュ無効化を適用
|
||||
applyNoCachePolicy();
|
||||
|
||||
const rootPrefix = getWikiRootPrefix();
|
||||
|
||||
// iframeが配置されていない場合のみJS動的レンダリング(フォールバック)
|
||||
|
||||
Reference in new issue
Block a user