Communitygithub.com

Contournement du Cache SiteGround

Contourne la mise en cache SiteGround (SG CachePress + LiteSpeed) pour le développement WordPress. Ajoute un code d'invalidation de cache aux thèmes enfants pour des tests de développement en temps réel.

Qu'est-ce que Contournement du Cache SiteGround ?

Cette compétence vise à contourner les systèmes de cache de SiteGround (SG CachePress et LiteSpeed) lors du développement WordPress. Elle ajoute un code PHP au fichier `functions.php` d'un thème enfant qui désactive le cache côté serveur pour les administrateurs connectés, envoie des en-têtes anti-cache (no-cache, no-store), et invalide le cache du navigateur en ajoutant un timestamp aux URLs CSS/JS. Une bannière de version visible uniquement par les administrateurs confirme que le thème est bien chargé sans cache. La compétence suit un workflow strict interdisant tout déploiement en production (Staging uniquement), ce qui est rappelé avec insistance dans sa documentation. Elle est conçue pour les développeurs WordPress utilisant un hébergement SiteGround, et peut être injectée automatiquement via un script Bash, copiée manuellement, ou appliquée via une commande dans Claude.

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

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Compétence de Contournement du Cache SiteGround

Contourne la mise en cache SiteGround (SG CachePress + LiteSpeed) pour le développement WordPress. Ajoute un code d'invalidation de cache aux thèmes enfants pour des tests de développement en temps réel.


⛔ CRITIQUE : EN STAGING UNIQUEMENT - JAMAIS EN PRODUCTION

Claude a l'interdiction de déployer sur des sites de production.

ActionAutorisé ?
Déployer en staging✅ OUI
Déployer en production❌ ABSOLUMENT JAMAIS
Lire depuis la production✅ OUI (lecture seule)
Écrire vers la production❌ ABSOLUMENT JAMAIS

Si l'utilisateur demande un déploiement en production :

  1. REFUSEZ la demande
  2. Expliquez que les déploiements en production doivent être effectués manuellement par l'utilisateur
  3. Proposez de déployer en staging à la place

Les chemins de production sont BLOQUÉS. Tout chemin qui ne contient PAS "staging" est interdit pour les écritures.


Informations Requises

Avant d'utiliser cette compétence, Claude demandera :

  1. Identifiants FTP/SFTP

    • Nom d'hôte (ex. ftp.example.com)
    • Nom d'utilisateur
    • Mot de passe
    • Port (généralement 21 pour FTP, 22 pour SFTP)
  2. URLs du site

    • URL de staging (ex. https://staging.example.com)
    • URL de production (PAS nécessaire - Claude n'y déploiera pas)
  3. Chemin du thème

    • Nom du dossier du thème enfant (ex. theme-enfant)

Stockez les identifiants dans le fichier CLAUDE.local.md du projet (ignoré par git) pour les sessions futures.


Workflow Uniquement en Staging

Développement local → Site de staging → [UTILISATEUR MANUELLEMENT] → Production
        ↑                     ↑                               ↑
    Claude édite         Claude déploie                  L'utilisateur déploie

Claude gère : Édition locale + Déploiement en staging L'utilisateur gère : Déploiement en production (via SiteGround, client FTP, ou manuellement)


Ce qu'il Fait

  1. Désactive la mise en cache côté serveur pour les administrateurs - LiteSpeed Cache + SG CachePress
  2. Ajoute des en-têtes no-cache - Empêche la mise en cache CDN/proxy
  3. Invalide le cache du navigateur - Ajoute un timestamp aux URLs CSS/JS
  4. Affiche une bannière de version - Confirmation visuelle du chargement du thème (administrateurs uniquement)

Le Code

Extrait PHP (à ajouter à functions.php)

<?php
/**
 * Contournement du cache SiteGround pour le développement
 * Désactive la mise en cache pour les administrateurs connectés
 * À SUPPRIMER OU DÉSACTIVER EN PRODUCTION une fois les tests terminés
 */

// Bannière de mode développement (affiche la version pour confirmer l'activation du thème)
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>';
    }
}

// Désactive toute la mise en cache pour les administrateurs
add_action('init', 'sg_disable_cache_for_dev');
function sg_disable_cache_for_dev() {
    if (current_user_can('administrator')) {
        // Désactiver LiteSpeed Cache
        if (!defined('LSCACHE_NO_CACHE')) {
            define('LSCACHE_NO_CACHE', true);
        }

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

        // Envoyer les en-têtes no-cache
        nocache_headers();

        // En-têtes supplémentaires pour le contournement 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');
    }
}

// Invalider le cache navigateur en ajoutant un timestamp aux CSS/JS du thème
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')) {
        // Invalider uniquement les ressources du thème
        $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;
}

Utilisation

Méthode 1 : Injection automatique via script

# Naviguez vers votre projet
cd /chemin/vers/projet-wordpress

# Exécutez le script d'injection
/root/.claude/skills/siteground-cache/add-cache-buster.sh ./wp-content/themes/votre-theme-enfant

Méthode 2 : Copie manuelle

  1. Copiez le code PHP ci-dessus
  2. Collez-le à la fin du fichier functions.php de votre thème enfant
  3. Téléchargez via FTP UNIQUEMENT EN STAGING
  4. Visitez le site de staging en tant qu'administrateur - vous devriez voir la bannière de version

Méthode 3 : Via Claude

Demandez simplement :

  • "Ajoute le contournement du cache SiteGround à ce thème"
  • "Active le mode développement pour SiteGround"
  • "Ajoute le cache buster à functions.php"

Claude déploiera uniquement en staging.


Workflow de Déploiement (STAGING UNIQUEMENT)

Étape 1 : Obtenir les identifiants (Demander à l'utilisateur)

Avant de déployer, demandez à l'utilisateur :

J'ai besoin des identifiants FTP pour déployer en STAGING. Veuillez fournir :
1. Hôte FTP (ex. ftp.votredomaine.com)
2. Nom d'utilisateur FTP
3. Mot de passe FTP
4. Chemin du site de staging (ex. staging.votredomaine.com/public_html)

Étape 2 : Déployer en staging

# STAGING UNIQUEMENT - Jamais en production !
lftp -u "utilisateur,motdepasse" -e "
    set ssl:verify-certificate no
    mirror -R ./theme-enfant staging.example.com/public_html/wp-content/themes/theme-enfant
    bye
" ftp://ftp.example.com

Étape 3 : Vérifier en staging

  1. Visitez le site de staging en tant qu'administrateur
  2. Confirmez que la bannière de développement apparaît (en bas à droite)
  3. Testez que les modifications CSS/JS sont visibles
  4. Vérifiez l'absence d'erreurs PHP

Étape 4 : L'utilisateur déploie en production

Claude n'effectue PAS cette étape. Dites à l'utilisateur :

Les modifications sont prêtes en staging. Pour déployer en production :

Option 1 : SiteGround Site Tools
  - Allez dans Site Tools > WordPress > Staging
  - Cliquez sur "Push to Live"

Option 2 : Client FTP (FileZilla, Cyberduck, etc.)
  - Téléchargez depuis le staging
  - Téléversez vers la production

Option 3 : Copie manuelle des fichiers via FTP

Comment Chaque Partie Fonctionne

1. Contournement de LiteSpeed Cache

define('LSCACHE_NO_CACHE', true);

Le plugin LiteSpeed Cache vérifie cette constante et ignore la mise en cache lorsqu'elle est définie.

2. Contournement de SG CachePress

define('SG_CACHEPRESS_NO_CACHE', true);

Le plugin de mise en cache de SiteGround respecte cette constante.

3. En-têtes HTTP

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

Indique aux navigateurs et aux CDN de ne pas mettre en cache la réponse.

4. Invalidation du cache des ressources

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

Ajoute ?v=1704567890 aux URLs CSS/JS. Comme le timestamp change chaque seconde, les navigateurs récupèrent toujours des fichiers frais.


Dépannage

La bannière ne s'affiche pas ?

  • Assurez-vous d'être connecté en tant qu'administrateur
  • Vérifiez que le thème enfant est activé (Apparence > Thèmes)
  • Vérifiez les erreurs PHP dans le journal des erreurs

Vous voyez encore du contenu en cache ?

  1. Essayez une fenêtre de navigation privée/incognito
  2. Videz manuellement le cache du navigateur
  3. Vérifiez SiteGround Site Tools > Speed > Caching > Purge Cache
  4. Vérifiez si Cloudflare est en frontal (vous devrez purger là aussi)

Les modifications CSS n'apparaissent pas ?

  • Affichez le code source de la page et vérifiez si le timestamp ?v= est présent sur les URLs CSS
  • Rafraîchissement forcé : Ctrl+Shift+R (Windows) ou Cmd+Shift+R (Mac)

Fichiers de Cette Compétence

/root/.claude/skills/siteground-cache/
├── SKILL.md                 # Cette documentation
├── add-cache-buster.sh      # Script d'injection automatique
├── cache-buster.php         # Extrait PHP autonome
└── remove-cache-buster.sh   # Script de suppression

Exemple de Modèle CLAUDE.local.md

Stockez ceci dans votre projet (ignoré par git) :

# Identifiants SiteGround (NE PAS COMMITTER)

## Accès FTP
- Hôte : ftp.example.com
- Utilisateur : [email protected]
- Mot de passe : votre-mot-de-passe
- Port : 21

## URLs du site
- Staging : https://staging.example.com
- Production : https://example.com (LECTURE SEULE pour Claude)

## Chemins des thèmes
- Staging : staging.example.com/public_html/wp-content/themes/theme-enfant
- Production : INTERDITE (l'utilisateur déploie manuellement)

Activités Connexes

  • wp-docker - Développement WordPress local
  • wp-performance - Optimisation du cache en production
  • visual-qa - Tests par capture d'écran après modifications

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

Skills associés