Communitygithub.com

ComeOnOliver/skillshub

绕过 SiteGround 缓存(SG CachePress + LiteSpeed)以进行 WordPress 开发。向子主题添加缓存破坏代码,实现实时开发测试。

skillshub 是什么?

这是一个专门用于绕过 SiteGround 主机平台(SG CachePress + LiteSpeed)缓存的 AI 助手技能。它通过向 WordPress 子主题的 functions.php 文件中注入 PHP 代码片段,为登录的管理员禁用服务器端缓存、添加无缓存 HTTP 标头,并对主题的 CSS/JS 文件添加时间戳查询参数以破坏浏览器缓存。该技能还包含一个可视化的版本横幅,用于确认主题正在加载。 **核心功能与用途**:此技能对于需要在 SiteGround 平台上频繁修改并即时查看主题效果的 WordPress 开发者来说非常实用。它解决了站内缓存和浏览器缓存导致的开发困难,让开发者可以实时验证代码改动,而无需手动清除缓存。 **平台支持与限制**:该技能专门针对 SiteGround 平台(尤其是部署了 LiteSpeed 和 SG CachePress 插件的站点)设计。它提供了一个**仅限暂存环境**的工作流程,明确禁止向生产环境部署代码。AI 助手被强制要求只能从用户处获取 FTP/SFTP 凭证,并将代码部署到暂存站点,生产环境的部署必须由用户手动完成。 **工作原理与使用方式**:该技能通过在 functions.php 中定义 `LSCACHE_NO_CACHE` 和 `SG_CACHEPRESS_NO_CACHE` 常量来禁用服务器端缓存,调用 `nocache_headers()` 设置 HTTP 标头防止浏览器和 CDN 缓存,并使用 `add_query_arg('v', time(), $src)` 为 CSS/JS 链接添加时间戳以实现资产缓存破坏。用户可以通过多种方式使用此技能:直接要求 AI 添加缓存破坏功能、手动复制粘贴提供的 PHP 代码,或使用技能包中包含的自动注入脚本。所有凭证信息应安全地存储在项目中的 `CLAUDE.local.md` 文件内(该文件已被添加至 .gitignore)。

兼容平台✓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. 站点 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. 添加无缓存标头 - 防止 CDN/代理缓存
  3. 破坏浏览器缓存 - 为 CSS/JS URL 添加时间戳
  4. 显示版本横幅 - 视觉确认主题正在加载(仅限管理员)

代码

PHP 代码片段(添加到 functions.php)

<?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 缓存
        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 仅会部署到暂存环境。


部署工作流程(仅限暂存环境)

第一步:获取凭据(询问用户)

部署前,请向用户询问:

我需要 FTP 凭据才能部署到暂存环境。请提供:
1. FTP 主机(例如 ftp.yourdomain.com)
2. FTP 用户名
3. FTP 密码
4. 暂存站点路径(例如 staging.yourdomain.com/public_html)

第二步:部署到暂存环境

# 仅限暂存环境 - 绝不部署到生产环境!
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

第三步:在暂存环境验证

  1. 以管理员身份访问暂存站点
  2. 确认开发横幅出现(右下角)
  3. 测试 CSS/JS 更改是否可见
  4. 检查 PHP 错误

第四步:用户部署到生产环境

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 缓存插件会检查此常量,并在定义时跳过缓存。

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 站点工具 > 速度 > 缓存 > 清除缓存
  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 访问
- Host: ftp.example.com
- User: [email protected]
- Pass: your-password
- Port: 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

相关技能