Communitygithub.com

ComeOnOliver/skillshub

繞過 SiteGround 的快取機制(SG CachePress + LiteSpeed),在 WordPress 開發時加入快取破壞程式碼至子佈景主題,實現即時開發測試。

skillshub 是什麼?

這個技能專為 WordPress 開發者設計,旨在繞過 SiteGround 主機的伺服器端快取(SG CachePress 和 LiteSpeed),讓開發者能夠在子佈景主題上進行即時測試,確保每次修改都能立即反映。它透過在 functions.php 中加入 PHP 程式碼,為管理員停用快取、傳送無快取標頭並對 CSS/JS 加入時間戳記來強制瀏覽器重新下載資源。此技能支援 FTP/SFTP 部署,但嚴格限制僅能部署到測試站(staging),生產環境(production)的部署需由使用者手動完成。它包含自動注入腳本、手動複製及透過自然語言請求等三種使用方式,並提供詳細的故障排除指南。

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

SiteGround 快取破壞技能

繞過 SiteGround 的快取機制(SG CachePress + LiteSpeed)進行 WordPress 開發。在子佈景主題中加入快取破壞程式碼,實現即時開發測試。


⛔ 關鍵提醒:僅限測試站 - 絕對不能用於正式站

Claude 嚴禁部署至正式站點。

操作是否允許?
部署至測試站✅ 是
部署至正式站❌ 絕對不可以
從正式站讀取✅ 是(唯讀)
寫入正式站❌ 絕對不可以

如果使用者要求部署至正式站:

  1. 拒絕該請求
  2. 說明正式站部署必須由使用者手動完成
  3. 提議改為部署至測試站

正式站路徑已封鎖。 任何不包含 "staging" 的路徑皆禁止寫入。


必要資訊

使用此技能前,Claude 會詢問:

  1. FTP/SFTP 憑證

    • 主機名稱(例如 ftp.example.com)
    • 使用者名稱
    • 密碼
    • 連接埠(FTP 通常為 21,SFTP 為 22)
  2. 網站網址

    • 測試站網址(例如 https://staging.example.com)
    • 正式站網址(不需要 - Claude 不會部署到那裡)
  3. 佈景主題路徑

    • 子佈景主題資料夾名稱(例如 theme-child)

將憑證儲存在專案的 CLAUDE.local.md(已被 gitignore)以便未來工作階段使用。


僅限測試站的工作流程

本機開發 → 測試站 → [使用者手動] → 正式站
   ↑              ↑               ↑
Claude 編輯   Claude 部署    使用者部署

Claude 負責:本機編輯 + 測試站部署 使用者負責:正式站部署(透過 SiteGround、FTP 用戶端或手動)


功能說明

  1. 為管理員停用伺服器端快取 - LiteSpeed Cache + SG CachePress
  2. 加入無快取標頭 - 防止 CDN/代理快取
  3. 破壞瀏覽器快取 - 為 CSS/JS 網址加入時間戳記
  4. 顯示版本橫幅 - 視覺確認佈景主題已載入(僅管理員可見)

程式碼

PHP 程式碼片段(新增至 functions.php)

/**
 * SiteGround 開發用快取破壞工具
 * 為已登入的管理員停用快取
 * 測試完成後請在正式站移除或停用
 */

// 開發模式橫幅(顯示版本以確認佈景主題已啟用)
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);
        }

        // 傳送無快取標頭
        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 快取繞過

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 網址後加上 ?v=1704567890。由於時間戳記每秒變化,瀏覽器總是取得最新檔案。


故障排除

橫幅未顯示?

  • 確認您已登入為管理員
  • 檢查子佈景主題是否已啟用(外觀 > 佈景主題)
  • 檢查錯誤日誌中是否有 PHP 錯誤

仍看到快取內容?

  1. 嘗試無痕/私密瀏覽視窗
  2. 手動清除瀏覽器快取
  3. 檢查 SiteGround Site Tools > Speed > Caching > Purge Cache
  4. 檢查前方是否有 Cloudflare(也需要清除其快取)

CSS 變更未出現?

  • 檢視頁面原始碼,檢查 CSS 網址是否有 ?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

## 網站網址
- 測試站: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

相關技能