Communitygithub.com

SiteGround Cache Buster スキル

WordPress開発においてSiteGroundのキャッシュ(SG CachePress + LiteSpeed)をバイパスします。子テーマにキャッシュバスティングコードを追加し、リアルタイムな開発テストを実現します。

SiteGround Cache Buster スキル とは?

このスキルは、SiteGroundホスティング上のWordPress開発環境で、サーバーサイドキャッシュ(LiteSpeed CacheおよびSG CachePress)をバイパスするためのツールです。管理者ログイン時にキャッシュを無効化し、no-cacheヘッダーを送信してCDN/プロキシキャッシュを防止します。さらに、CSS/JSのURLにタイムスタンプを付与することでブラウザキャッシュを破棄し、テーマの読み込みを確認するバージョンバナーを表示します。**重要な制限事項として、このスキルはステージングサイトでのみ使用可能で、本番環境へのデプロイは固く禁止されています。** ClaudeはFTP/SFTPを使ってステージングにコードをデプロイし、ユーザーが手動で本番環境に反映するワークフローを前提としています。スキルにはPHPスニペット、自動注入スクリプト、手動設定手順が含まれ、CLAUDE.local.mdにFTP認証情報を安全に保存して再利用できます。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/crazyswami/siteground-cache

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

SiteGround Cache Buster スキル は何をしますか?

WordPress開発においてSiteGroundのキャッシュ(SG CachePress + LiteSpeed)をバイパスします。子テーマにキャッシュバスティングコードを追加し、リアルタイムな開発テストを実現します。


⛔ 重要: ステージングのみ - 本番環境では絶対に使用しないでください

Claudeは本番サイトへのデプロイを禁止されています。

アクション許可?
ステージングへのデプロイ✅ はい
本番環境へのデプロイ❌ 絶対にしない
本番環境からの読み取り✅ はい(読み取り専用)
本番環境への書き込み❌ 絶対にしない

ユーザーが本番環境へのデプロイを依頼した場合:

  1. リクエストを拒否する
  2. 本番環境へのデプロイはユーザーが手動で行う必要があることを説明する
  3. 代わりにステージングへのデプロイを提案する

本番環境のパスはブロックされています。 書き込みは「staging」を含まないパスでは許可されません。


必要な情報

このスキルを使用する前に、Claudeは以下を尋ねます:

  1. FTP/SFTP認証情報

    • ホスト名(例: ftp.example.com)
    • ユーザー名
    • パスワード
    • ポート(通常FTPは21、SFTPは22)
  2. サイトURL

    • ステージングURL(例: https://staging.example.com)
    • 本番URL(不要 - Claudeはそこにデプロイしません)
  3. テーマパス

    • 子テーマフォルダ名(例: theme-child)

認証情報はプロジェクトのCLAUDE.local.mdに保存してください(gitignore対象)。今後のセッションで再利用されます。


ステージングのみのワークフロー

ローカル開発 → ステージングサイト → [ユーザーが手動] → 本番
        ↑              ↑                   ↑
   Claudeが編集  Claudeがデプロイ     ユーザーがデプロイ

Claudeが担当: ローカル編集 + ステージングデプロイ ユーザーが担当: 本番デプロイ(SiteGround、FTPクライアント、または手動)


機能概要

  1. 管理者向けサーバーサイドキャッシュを無効化 - LiteSpeed Cache + SG CachePress
  2. no-cacheヘッダーを追加 - CDN/プロキシキャッシュを防止
  3. ブラウザキャッシュを破棄 - CSS/JSのURLにタイムスタンプを追加
  4. バージョンバナーを表示 - テーマが読み込まれていることを視覚的に確認(管理者のみ)

コード

PHPスニペット(functions.phpに追加)

<?php
/**
 * SiteGround Cache Buster for Development
 * ログイン中の管理者に対してキャッシュを無効化
 * テスト完了後は本番環境で削除または無効化すること
 */

// 開発モードバナー(テーマがアクティブであることを確認するバージョン表示)
add_action('wp_head', 'sg_dev_mode_banner');
function sg_dev_mode_banner() {
    if (current_user_can('administrator')) {
        $theme = wp_get_theme();
        $version = $theme->get('Version');
        $name = $theme->get('Name');
        echo '<style>
            .sg-dev-banner {
                position: fixed;
                bottom: 20px;
                right: 20px;
                background: #34889A;
                color: white;
                padding: 10px 20px;
                border-radius: 8px;
                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
                font-size: 12px;
                z-index: 999999;
                box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            }
        </style>
        <div class="sg-dev-banner">
            ' . esc_html($name) . ' v' . esc_html($version) . ' - ' . date('M j, H:i') . '
        </div>';
    }
}

// 管理者のすべてのキャッシュを無効化
add_action('init', 'sg_disable_cache_for_dev');
function sg_disable_cache_for_dev() {
    if (current_user_can('administrator')) {
        // LiteSpeed Cacheを無効化
        if (!defined('LSCACHE_NO_CACHE')) {
            define('LSCACHE_NO_CACHE', true);
        }

        // SG Optimizer/CachePressを無効化
        if (!defined('SG_CACHEPRESS_NO_CACHE')) {
            define('SG_CACHEPRESS_NO_CACHE', true);
        }

        // no-cacheヘッダーを送信
        nocache_headers();

        // CDNバイパス用の追加ヘッダー
        header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
        header('Pragma: no-cache');
        header('Expires: Thu, 01 Jan 1970 00:00:00 GMT');
    }
}

// テーマのCSS/JSにタイムスタンプを追加してブラウザキャッシュを破棄
add_filter('style_loader_src', 'sg_bust_asset_cache', 999);
add_filter('script_loader_src', 'sg_bust_asset_cache', 999);
function sg_bust_asset_cache($src) {
    if (current_user_can('administrator')) {
        // テーマアセットのみキャッシュを破棄
        $theme_uri = get_stylesheet_directory_uri();
        $parent_uri = get_template_directory_uri();

        if (strpos($src, $theme_uri) !== false || strpos($src, $parent_uri) !== false) {
            $src = add_query_arg('v', time(), $src);
        }
    }
    return $src;
}

使用方法

方法1: スクリプトによる自動注入

# プロジェクトに移動
cd /path/to/wordpress-project

# インジェクタースクリプトを実行
/root/.claude/skills/siteground-cache/add-cache-buster.sh ./wp-content/themes/your-child-theme

方法2: 手動コピー

  1. 上記のPHPコードをコピー
  2. 子テーマのfunctions.phpの末尾にペースト
  3. FTPでステージングのみにアップロード
  4. 管理者としてステージングサイトにアクセス - バージョンバナーが表示されることを確認

方法3: Claude経由

次のように依頼するだけ:

  • 「このテーマにSiteGroundキャッシュバスティングを追加して」
  • 「SiteGroundの開発モードを有効にして」
  • 「functions.phpにキャッシュバスターを追加して」

Claudeはステージングにのみデプロイします。


デプロイワークフロー(ステージングのみ)

ステップ1: 認証情報を取得(ユーザーに尋ねる)

デプロイ前にユーザーに尋ねてください:

ステージングにデプロイするためにFTP認証情報が必要です。以下を教えてください:
1. FTPホスト(例: ftp.yourdomain.com)
2. FTPユーザー名
3. FTPパスワード
4. ステージングサイトのパス(例: staging.yourdomain.com/public_html)

ステップ2: ステージングにデプロイ

# ステージングのみ - 本番環境では絶対にしないでください!
lftp -u "user,password" -e "
    set ssl:verify-certificate no
    mirror -R ./child-theme staging.example.com/public_html/wp-content/themes/child-theme
    bye
" ftp://ftp.example.com

ステップ3: ステージングで確認

  1. 管理者としてステージングサイトにアクセス
  2. 開発バナーが表示されていることを確認(右下)
  3. CSS/JSの変更が反映されていることをテスト
  4. PHPエラーがないか確認

ステップ4: ユーザーが本番環境にデプロイ

Claudeはこの手順を実行しません。 ユーザーに伝えてください:

変更はステージングで準備完了です。本番環境にデプロイするには:

オプション1: SiteGround Site Tools
  - Site Tools > WordPress > Staging に移動
  - 「Push to Live」をクリック

オプション2: FTPクライアント(FileZilla, Cyberduckなど)
  - ステージングからダウンロード
  - 本番環境にアップロード

オプション3: FTPによる手動ファイルコピー

各機能の仕組み

1. LiteSpeed Cacheバイパス

define('LSCACHE_NO_CACHE', true);

LiteSpeed Cacheプラグインはこの定数をチェックし、設定時にキャッシュをスキップします。

2. SG CachePressバイパス

define('SG_CACHEPRESS_NO_CACHE', true);

SiteGroundのキャッシングプラグインはこの定数を尊重します。

3. HTTPヘッダー

nocache_headers();
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');

ブラウザとCDNに対してレスポンスをキャッシュしないように指示します。

4. アセットキャッシュバスティング

add_query_arg('v', time(), $src);

CSS/JSのURLに?v=1704567890を追加します。タイムスタンプが毎秒変化するため、ブラウザは常に最新のファイルを取得します。


トラブルシューティング

バナーが表示されない?

  • 管理者としてログインしているか確認
  • 子テーマが有効化されているか確認(外観 > テーマ)
  • エラーログでPHPエラーを確認

キャッシュされたコンテンツがまだ表示される?

  1. シークレット/プライベートブラウザウィンドウを試す
  2. ブラウザキャッシュを手動でクリア
  3. SiteGround Site Tools > Speed > Caching > Purge Cache を確認
  4. Cloudflareが前面にある場合は、そちらもパージする必要あり

CSSの変更が反映されない?

  • ページソースを表示し、CSSのURLに?v=タイムスタンプが付いているか確認
  • ハードリフレッシュ: Ctrl+Shift+R(Windows)または Cmd+Shift+R(Mac)

このスキルのファイル

/root/.claude/skills/siteground-cache/
├── SKILL.md                 # このドキュメント
├── add-cache-buster.sh      # 自動注入スクリプト
├── cache-buster.php         # スタンドアロンPHPスニペット
└── remove-cache-buster.sh   # 削除スクリプト

CLAUDE.local.mdテンプレート例

プロジェクトに保存(gitignore対象):

# SiteGround認証情報(コミットしないでください)

## FTPアクセス
- ホスト: ftp.example.com
- ユーザー: [email protected]
- パスワード: your-password
- ポート: 21

## サイトURL
- ステージング: https://staging.example.com
- 本番: https://example.com(Claudeは読み取り専用)

## テーマパス
- ステージング: staging.example.com/public_html/wp-content/themes/theme-child
- 本番: アクセス禁止(ユーザーが手動デプロイ)

関連情報

  • wp-docker - ローカルWordPress開発環境
  • wp-performance - 本番環境のキャッシュ最適化
  • visual-qa - 変更後のスクリーンショットテスト

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル