jpskill.com
🛠️ 開発・MCP コミュニティ

siteground-cache

Bypass SiteGround caching (SG CachePress + LiteSpeed) for WordPress development. Adds cache-busting code to child themes for real-time development testing.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o siteground-cache.zip https://jpskill.com/download/18118.zip && unzip -o siteground-cache.zip && rm siteground-cache.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18118.zip -OutFile "$d\siteground-cache.zip"; Expand-Archive "$d\siteground-cache.zip" -DestinationPath $d -Force; ri "$d\siteground-cache.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して siteground-cache.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → siteground-cache フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

[Skill 名] siteground-cache

SiteGround Cache Buster Skill

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 (git対象外) に認証情報を保存してください。


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

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

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


処理内容

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

コード

PHP スニペット (functions.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経由

以下のように尋ねてください:

  • "Add SiteGround cache busting to this theme"
  • "Enable dev mode for SiteGround"
  • "Add cache buster to 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はこのステップを実行しません。 ユーザーに伝えてください

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

SiteGround Cache Buster Skill

Bypass SiteGround caching (SG CachePress + LiteSpeed) for WordPress development. Adds cache-busting code to child themes for real-time development testing.


⛔ CRITICAL: STAGING ONLY - NEVER PRODUCTION

Claude is FORBIDDEN from deploying to production sites.

Action Allowed?
Deploy to staging ✅ YES
Deploy to production ABSOLUTELY NEVER
Read from production ✅ YES (read-only)
Write to production ABSOLUTELY NEVER

If user asks to deploy to production:

  1. REFUSE the request
  2. Explain that production deployments must be done manually by the user
  3. Offer to deploy to staging instead

Production paths are BLOCKED. Any path that does NOT contain "staging" is off-limits for writes.


Required Information

Before using this skill, Claude will ask for:

  1. FTP/SFTP Credentials

    • Hostname (e.g., ftp.example.com)
    • Username
    • Password
    • Port (usually 21 for FTP, 22 for SFTP)
  2. Site URLs

    • Staging URL (e.g., https://staging.example.com)
    • Production URL (NOT needed - Claude won't deploy there)
  3. Theme Path

    • Child theme folder name (e.g., theme-child)

Store credentials in project's CLAUDE.local.md (gitignored) for future sessions.


Staging-Only Workflow

Local Development → Staging Site → [USER MANUALLY] → Production
        ↑              ↑                   ↑
    Claude edits   Claude deploys     USER deploys

Claude handles: Local editing + Staging deployment User handles: Production deployment (via SiteGround, FTP client, or manually)


What It Does

  1. Disables server-side caching for admins - LiteSpeed Cache + SG CachePress
  2. Adds no-cache headers - Prevents CDN/proxy caching
  3. Busts browser cache - Adds timestamp to CSS/JS URLs
  4. Shows version banner - Visual confirmation theme is loading (admin only)

The Code

PHP Snippet (add to functions.php)

/**
 * SiteGround Cache Buster for Development
 * Disables caching for logged-in administrators
 * REMOVE OR DISABLE IN PRODUCTION when done testing
 */

// Development mode banner (shows version to confirm theme is active)
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>';
    }
}

// Disable all caching for administrators
add_action('init', 'sg_disable_cache_for_dev');
function sg_disable_cache_for_dev() {
    if (current_user_can('administrator')) {
        // Disable LiteSpeed Cache
        if (!defined('LSCACHE_NO_CACHE')) {
            define('LSCACHE_NO_CACHE', true);
        }

        // Disable SG Optimizer/CachePress
        if (!defined('SG_CACHEPRESS_NO_CACHE')) {
            define('SG_CACHEPRESS_NO_CACHE', true);
        }

        // Send no-cache headers
        nocache_headers();

        // Additional headers for CDN bypass
        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');
    }
}

// Bust browser cache by adding timestamp to theme 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')) {
        // Only bust cache for theme assets
        $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;
}

Usage

Method 1: Auto-inject via Script

# Navigate to your project
cd /path/to/wordpress-project

# Run the injector script
/root/.claude/skills/siteground-cache/add-cache-buster.sh ./wp-content/themes/your-child-theme

Method 2: Manual Copy

  1. Copy the PHP code above
  2. Paste at the end of your child theme's functions.php
  3. Upload via FTP TO STAGING ONLY
  4. Visit staging site as admin - you should see the version banner

Method 3: Via Claude

Just ask:

  • "Add SiteGround cache busting to this theme"
  • "Enable dev mode for SiteGround"
  • "Add cache buster to functions.php"

Claude will only deploy to staging.


Deployment Workflow (STAGING ONLY)

Step 1: Get Credentials (Ask User)

Before deploying, ask the user:

I need FTP credentials to deploy to STAGING. Please provide:
1. FTP Host (e.g., ftp.yourdomain.com)
2. FTP Username
3. FTP Password
4. Staging site path (e.g., staging.yourdomain.com/public_html)

Step 2: Deploy to Staging

# STAGING ONLY - Never production!
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

Step 3: Verify on Staging

  1. Visit staging site as admin
  2. Confirm dev banner appears (bottom-right)
  3. Test CSS/JS changes are visible
  4. Check for PHP errors

Step 4: User Deploys to Production

Claude does NOT do this step. Tell the user:

The changes are ready on staging. To deploy to production:

Option 1: SiteGround Site Tools
  - Go to Site Tools > WordPress > Staging
  - Click "Push to Live"

Option 2: FTP Client (FileZilla, Cyberduck, etc.)
  - Download from staging
  - Upload to production

Option 3: Manual file copy via FTP

How Each Part Works

1. LiteSpeed Cache Bypass

define('LSCACHE_NO_CACHE', true);

LiteSpeed Cache plugin checks for this constant and skips caching when set.

2. SG CachePress Bypass

define('SG_CACHEPRESS_NO_CACHE', true);

SiteGround's caching plugin respects this constant.

3. HTTP Headers

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

Tells browsers and CDNs not to cache the response.

4. Asset Cache Busting

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

Adds ?v=1704567890 to CSS/JS URLs. Since the timestamp changes every second, browsers always fetch fresh files.


Troubleshooting

Banner not showing?

  • Make sure you're logged in as Administrator
  • Check if child theme is activated (Appearance > Themes)
  • Check for PHP errors in the error log

Still seeing cached content?

  1. Try incognito/private browser window
  2. Clear browser cache manually
  3. Check SiteGround Site Tools > Speed > Caching > Purge Cache
  4. Check if Cloudflare is in front (need to purge there too)

CSS changes not appearing?

  • View page source and check if ?v= timestamp is on CSS URLs
  • Hard refresh: Ctrl+Shift+R (Windows) or Cmd+Shift+R (Mac)

Files in This Skill

/root/.claude/skills/siteground-cache/
├── SKILL.md                 # This documentation
├── add-cache-buster.sh      # Auto-inject script
├── cache-buster.php         # Standalone PHP snippet
└── remove-cache-buster.sh   # Removal script

Example CLAUDE.local.md Template

Store this in your project (gitignored):

# SiteGround Credentials (DO NOT COMMIT)

## FTP Access
- Host: ftp.example.com
- User: user@example.com
- Pass: your-password
- Port: 21

## Site URLs
- Staging: https://staging.example.com
- Production: https://example.com (READ-ONLY for Claude)

## Theme Paths
- Staging: staging.example.com/public_html/wp-content/themes/theme-child
- Production: OFF-LIMITS (user deploys manually)

Related

  • wp-docker - Local WordPress development
  • wp-performance - Production caching optimization
  • visual-qa - Screenshot testing after changes