# wp-media/wp-rocket architecture

> Architecture diagram of the GitHub repository wp-media/wp-rocket, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wp-media/wp-rocket
- Repository: https://github.com/wp-media/wp-rocket

## Overview

WP Rocket is a WordPress performance plugin: its primary workflow configures caching and delivery optimizations, then serves transformed pages and assets to site visitors. The tree also shows CDN management, critical-CSS and above-the-fold media handling, admin settings, scheduled work, insights, and compatibility integrations. Sampled code confirms cache purging, CDN state management, Critical CSS file handling, and WordPress hook registration; some broader feature links reflect the README and directory structure rather than inspected implementations.

Main entry points: [`inc/Engine/Cache/Purge.php`](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Cache/Purge.php) (Page cache), [`inc/3rd-party/3rd-party.php`](https://github.com/wp-media/wp-rocket/blob/develop/inc/3rd-party/3rd-party.php) (Plugin compatibility), [`inc/Engine/CDN/CDN.php`](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CDN/CDN.php) (CDN management), [`inc/Engine/Admin/Settings/Page.php`](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/Settings/Page.php) (Admin settings UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Page optimization"]
  node_critical_css["Critical CSS<br/>[DataManager.php]"]
  node_above_fold["Above-fold media<br/>[Controller.php]"]
  node_lazyload["Lazy loading<br/>[Assets.php]"]
  node_css_extract["CSS extraction<br/>[Subscriber.php]"]
  node_minify["Asset minification<br/>[Minify.php]"]
  node_head["HTML head handling<br/>[Subscriber.php]"]
end

subgraph group_delivery["Cache and CDN"]
  node_cache["Page cache<br/>[Purge.php]"]
  node_cache_state["Cache state<br/>[WPCache.php]"]
  node_cdn["CDN management<br/>[CDN.php]"]
  node_cdn_render["CDN rendering<br/>[Controller.php]"]
  node_rocketcdn["RocketCDN lifecycle"]
end

subgraph group_admin["Admin and insights"]
  node_settings["Plugin settings<br/>[Settings.php]"]
  node_admin_ui["Admin settings UI<br/>[Page.php]"]
  node_insights["Rocket Insights<br/>[Controller.php]"]
  node_insights_jobs["Insights jobs<br/>[Manager.php]"]
  node_recommendations["Recommendations<br/>[DataManager.php]"]
  node_job_queue["Job processing<br/>[Queue.php]"]
  node_event_manager["Hook subscribers"]
end

subgraph group_integrations["Compatibility and services"]
  node_cloudflare["Cloudflare addon<br/>[Cloudflare.php]"]
  node_varnish["Varnish addon<br/>[Varnish.php]"]
  node_compat["Plugin compatibility<br/>[3rd-party.php]"]
  node_wpengine["WP Engine<br/>[WPEngine.php]"]
end

node_visitor(("Site visitor"))
node_wordpress(("WordPress"))
node_cdn_service(("RocketCDN service"))
node_insights_service(("Insights service"))
node_cache_store[("WordPress cache")]
node_filesystem[("Plugin filesystem")]

node_visitor -->|"requests page"| node_wordpress
node_wordpress -->|"serves cached pages"| node_cache
node_cache -->|"uses cache state"| node_cache_state
node_cache -->|"purges cache"| node_cache_store
node_wordpress -->|"renders head"| node_head
node_wordpress -->|"extracts CSS"| node_css_extract
node_wordpress -->|"stores critical CSS"| node_critical_css
node_critical_css -->|"writes files"| node_filesystem
node_wordpress -->|"optimizes LCP media"| node_above_fold
node_wordpress -->|"lazy-loads assets"| node_lazyload
node_wordpress -->|"minifies assets"| node_minify
node_admin_ui -->|"edits settings"| node_settings
node_admin_ui -->|"admin requests"| node_wordpress
node_wordpress -->|"manages CDN"| node_cdn
node_cdn -->|"renders CDN settings"| node_cdn_render
node_cdn_render -->|"clears cache"| node_cache
node_cdn -->|"manages subscription"| node_rocketcdn
node_rocketcdn -->|"requests subscription data"| node_cdn_service
node_insights -->|"manages insight tests"| node_insights_jobs
node_insights_jobs -->|"schedules jobs"| node_job_queue
node_insights -.->|"requests insights"| node_insights_service
node_recommendations -->|"fetches recommendations"| node_insights_service
node_wordpress -->|"registers hooks"| node_event_manager
node_event_manager -->|"dispatches callbacks"| node_compat
node_compat -.->|"loads host compatibility"| node_wpengine
node_compat -.->|"loads addon"| node_cloudflare
node_compat -.->|"loads addon"| node_varnish
node_wpengine -.->|"purges host cache"| node_cache

click node_cache "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Cache/Purge.php"
click node_cache_state "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Cache/WPCache.php"
click node_cdn "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CDN/CDN.php"
click node_cdn_render "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CDN/Render/Controller.php"
click node_rocketcdn "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CDN/RocketCDN/DataManagerSubscriber.php"
click node_critical_css "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CriticalPath/DataManager.php"
click node_above_fold "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Media/AboveTheFold/Frontend/Controller.php"
click node_lazyload "https://github.com/wp-media/wp-rocket/blob/develop/inc/Dependencies/RocketLazyload/Assets.php"
click node_css_extract "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Common/ExtractCSS/Subscriber.php"
click node_minify "https://github.com/wp-media/wp-rocket/blob/develop/inc/Dependencies/Minify/Minify.php"
click node_head "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Common/Head/Subscriber.php"
click node_settings "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/Settings/Settings.php"
click node_admin_ui "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/Settings/Page.php"
click node_insights "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/RocketInsights/Controller.php"
click node_insights_jobs "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/RocketInsights/Jobs/Manager.php"
click node_recommendations "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/RocketInsights/Recommendations/DataManager.php"
click node_job_queue "https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Common/JobManager/Queue/Queue.php"
click node_event_manager "https://github.com/wp-media/wp-rocket/blob/develop/inc/classes/event-management/class-event-manager.php"
click node_cloudflare "https://github.com/wp-media/wp-rocket/blob/develop/inc/Addon/Cloudflare/Cloudflare.php"
click node_varnish "https://github.com/wp-media/wp-rocket/blob/develop/inc/Addon/Varnish/Varnish.php"
click node_compat "https://github.com/wp-media/wp-rocket/blob/develop/inc/3rd-party/3rd-party.php"
click node_wpengine "https://github.com/wp-media/wp-rocket/blob/develop/inc/ThirdParty/Hostings/WPEngine.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_critical_css,node_above_fold,node_lazyload,node_css_extract,node_minify,node_head toneBlue
class node_cache,node_cache_state,node_cdn,node_cdn_render,node_rocketcdn,node_cache_store,node_filesystem toneAmber
class node_settings,node_admin_ui,node_insights,node_insights_jobs,node_recommendations,node_job_queue,node_event_manager toneMint
class node_cloudflare,node_varnish,node_compat,node_wpengine toneRose
class node_visitor,node_wordpress,node_cdn_service,node_insights_service toneIndigo
```

## Components

### Page optimization

- [Critical CSS](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CriticalPath/DataManager.php): `inc/Engine/CriticalPath/DataManager.php`
- [Above-fold media](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Media/AboveTheFold/Frontend/Controller.php): `inc/Engine/Media/AboveTheFold/Frontend/Controller.php`
- [Lazy loading](https://github.com/wp-media/wp-rocket/blob/develop/inc/Dependencies/RocketLazyload/Assets.php): `inc/Dependencies/RocketLazyload/Assets.php`
- [CSS extraction](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Common/ExtractCSS/Subscriber.php): `inc/Engine/Common/ExtractCSS/Subscriber.php`
- [Asset minification](https://github.com/wp-media/wp-rocket/blob/develop/inc/Dependencies/Minify/Minify.php): `inc/Dependencies/Minify/Minify.php`
- [HTML head handling](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Common/Head/Subscriber.php): `inc/Engine/Common/Head/Subscriber.php`

### Cache and CDN

- [Page cache](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Cache/Purge.php): `inc/Engine/Cache/Purge.php`
- [Cache state](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Cache/WPCache.php): `inc/Engine/Cache/WPCache.php`
- [CDN management](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CDN/CDN.php): `inc/Engine/CDN/CDN.php`
- [CDN rendering](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CDN/Render/Controller.php): `inc/Engine/CDN/Render/Controller.php`
- [RocketCDN lifecycle](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/CDN/RocketCDN/DataManagerSubscriber.php): `inc/Engine/CDN/RocketCDN/DataManagerSubscriber.php`

### Admin and insights

- [Plugin settings](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/Settings/Settings.php): `inc/Engine/Admin/Settings/Settings.php`
- [Admin settings UI](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/Settings/Page.php): `inc/Engine/Admin/Settings/Page.php`
- [Rocket Insights](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/RocketInsights/Controller.php): `inc/Engine/Admin/RocketInsights/Controller.php`
- [Insights jobs](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/RocketInsights/Jobs/Manager.php): `inc/Engine/Admin/RocketInsights/Jobs/Manager.php`
- [Recommendations](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Admin/RocketInsights/Recommendations/DataManager.php): `inc/Engine/Admin/RocketInsights/Recommendations/DataManager.php`
- [Job processing](https://github.com/wp-media/wp-rocket/blob/develop/inc/Engine/Common/JobManager/Queue/Queue.php): `inc/Engine/Common/JobManager/Queue/Queue.php`
- [Hook subscribers](https://github.com/wp-media/wp-rocket/blob/develop/inc/classes/event-management/class-event-manager.php): `inc/classes/event-management/class-event-manager.php`

### Compatibility and services

- [Cloudflare addon](https://github.com/wp-media/wp-rocket/blob/develop/inc/Addon/Cloudflare/Cloudflare.php): `inc/Addon/Cloudflare/Cloudflare.php`
- [Varnish addon](https://github.com/wp-media/wp-rocket/blob/develop/inc/Addon/Varnish/Varnish.php): `inc/Addon/Varnish/Varnish.php`
- [Plugin compatibility](https://github.com/wp-media/wp-rocket/blob/develop/inc/3rd-party/3rd-party.php): `inc/3rd-party/3rd-party.php`
- [WP Engine](https://github.com/wp-media/wp-rocket/blob/develop/inc/ThirdParty/Hostings/WPEngine.php): `inc/ThirdParty/Hostings/WPEngine.php`

### Other components

- **Site visitor**
- **WordPress**
- **RocketCDN service**
- **Insights service**
- **WordPress cache**
- **Plugin filesystem**

## Connections

- Site visitor → WordPress: requests page
- WordPress → Page cache: serves cached pages
- Page cache → Cache state: uses cache state
- Page cache → WordPress cache: purges cache
- WordPress → HTML head handling: renders head
- WordPress → CSS extraction: extracts CSS
- WordPress → Critical CSS: stores critical CSS
- Critical CSS → Plugin filesystem: writes files
- WordPress → Above-fold media: optimizes LCP media
- WordPress → Lazy loading: lazy-loads assets
- WordPress → Asset minification: minifies assets
- Admin settings UI → Plugin settings: edits settings
- Admin settings UI → WordPress: admin requests
- WordPress → CDN management: manages CDN
- CDN management → CDN rendering: renders CDN settings
- CDN rendering → Page cache: clears cache
- CDN management → RocketCDN lifecycle: manages subscription
- RocketCDN lifecycle → RocketCDN service: requests subscription data
- Rocket Insights → Insights jobs: manages insight tests
- Insights jobs → Job processing: schedules jobs
- Rocket Insights → Insights service: requests insights
- Recommendations → Insights service: fetches recommendations
- WordPress → Hook subscribers: registers hooks
- Hook subscribers → Plugin compatibility: dispatches callbacks
- Plugin compatibility → WP Engine: loads host compatibility
- Plugin compatibility → Cloudflare addon: loads addon
- Plugin compatibility → Varnish addon: loads addon
- WP Engine → Page cache: purges host cache
