AstroPress
Enterprise Headless WordPress & Cloudflare R2 Suite for Astro
Marrying the unmatched authoring flexibility of WordPress with the instant speed of Astro SSR on Cloudflare Pages and Workers. Featuring 4-tier enterprise caching, pure PHP SigV4 Cloudflare R2 media offloading, and sub-150ms on-demand webhook revalidation.
Performance Benchmarks & Edge Efficiency
Measured in live production deployments under sustained high traffic
Served as cf-cache-status: HIT directly from 330+ Cloudflare edge POP nodes without hitting origin servers.
LCP 0.38s • CLS 0.00 • INP 8ms. Minimal DOM depth, zero layout shifts, and zero client hydration penalty on static shells.
Zero 50MB AWS SDK bloat. Native AWS Signature v4 engine runs seamlessly even on constrained shared hosting or high-performance VPS.
Cloudflare R2 provides $0 egress bandwidth. Edge cache shield absorbs 99.4% of traffic, keeping Worker invocations at zero.
Interactive Architecture Flowchart
Click any node below to inspect execution detailsEnd-to-end dataflow illustrating content editing, non-blocking webhook dispatch, edge purge, automated warming, and visitor delivery.
Cloudflare Zone & Worker Cache Purge
The Astro /api/revalidate endpoint verifies HMAC secret authenticity, calls Cloudflare API v4 to instantly purge affected URLs from the global Zone Cache (<150ms), and invokes caches.default.delete() inside Worker memory.
Authorization: Bearer CF_API_TOKEN caches.default.delete() 4-Tier Enterprise Caching Hierarchy
A layered architecture providing millisecond performance while guaranteeing instantaneous content freshness upon publication.
Redis Object Cache + LiteSpeed REST
WordPress VPS / Origin Caching
Serializes WP REST API responses in Redis RAM memory and intercepts LiteSpeed cache purges. Completely eliminates repeated MySQL queries when the Astro edge server requests raw article data.
1-Year Cloudflare POP Edge Cache
330+ Cloudflare Cities Across 120+ Countries
Serves pre-rendered HTML shells as cf-cache-status: HIT using modern Cloudflare Cache Rules.
Origin response headers enforce 1-year global edge retention (s-maxage=31536000).
Worker caches.default Deduplication
In-Memory Edge Runtime Cache
Intercepts inbound requests in Cloudflare Worker middleware prior to SSR route execution.
Matches against the Edge Cache API (caches.default) to eliminate redundant compute overhead and avoid cache stampedes.
Conditional Revalidation (max-age=0)
Client Browser Header Governance
Visitors receive max-age=0, must-revalidate.
The client browser performs a lightweight 304 conditional check against the nearest edge POP node, guaranteeing that article edits appear immediately without hard refreshes.
AstroPress Companion Plugin Features
A single unified WordPress companion plugin replacing 5+ separate heavy third-party plugins.
Pure PHP SigV4 R2 Engine
Replaces the 50MB AWS SDK with a custom <35KB pure PHP implementation of AWS Signature Version 4. Supports Dual Storage or R2-Only disk saver mode with custom CDN domain rewriting.
- Automatic media and srcset URL rewriting
- Live bucket discovery via Cloudflare API
- Zero external vendor composer dependencies
Non-Blocking Webhook Purge
Dispatches non-blocking async HTTP POST sockets on PHP shutdown with micro-queue debouncing. Triggers Cloudflare API v4 zone cache purges in <150ms without slowing down the WordPress editor.
- 0ms block editor saving overhead
- Exponential backoff cron retry on failed calls
- Audit delivery log with 1-click resend
Dual-Engine Edge Warmer
Eliminates edge cold boots by pre-warming purged URLs across Cloudflare POP nodes. Features an interactive AJAX progress bar for manual warmups and an automated background WP-Cron runner.
- Interactive progress bar with batch controls
- Background cron warming with pause/resume
- Automated sitemap URL discovery
Rank Math & Yoast SEO Bridge
Exposes fully rendered HTML <head> markup via REST endpoints (/wp-json/astropress/v1/head).
Rewrites origin URLs to the Astro domain and bridges 301/302 redirects to edge middleware.
- Schema JSON-LD & OpenGraph tags parity
- Edge redirection REST endpoint
- Rank Math 404 access log monitor
Dual-Stage Image Optimizer
Combines reSmush.it cloud compression with seamless fallback to server GD/Imagick. Automatically converts JPEG/PNG to WebP/AVIF formats on upload and strips heavy EXIF metadata.
- Automatic WebP & AVIF generation
- Intelligent dimension downscaling
- Visual upload interceptor bar
GitHub Releases & 1-Click Rollback
Native update pipeline checking iamgrisma/astropress releases directly from GitHub.
Employs WordPress Core's native Plugin_Upgrader sandbox with 1-click rollback support.
- Zero false positives from hosting scanners
- 1-click rollback to any historical release
- Full backward compatibility with legacy plugins
Battle-Tested Production Case Studies
Real-world websites currently powered by the AstroPress architecture in production.
TopNepali.com
Digital Publishing & National Election Platform in Nepal
TopNepali serves millions of monthly pageviews covering 753 local palikas, 165 parliamentary constituencies, and live election tallies. With AstroPress handling content revalidation and Cloudflare R2 media hosting:
Zero downtime during historic election traffic surges. Origin server load reduced by 98.7% compared to traditional monolithic WordPress.
Grisma Portfolio & Blog
Flagship Personal Architecture & Public Tools Showcase
Built with Astro 5+ on Cloudflare Pages Advanced Mode. Features instant search, technical article publishing, interactive civic tools, and automated edge warming powered directly by AstroPress.
Combines headless WordPress REST APIs with pure Cloudflare Worker edge SSR. Posts published in WordPress reflect globally in seconds.
Edge Implementation Blueprints
Production-ready code snippets for your Astro edge frontend on Cloudflare Pages and Workers.
// src/pages/api/revalidate.ts
import type { APIRoute } from 'astro';
export const POST: APIRoute = async ({ request, locals }) => {
const payload = await request.clone().json().catch(() => ({}));
const { slug, type, action, urls, secret } = payload;
// 1. Verify shared secret token
const expectedSecret = (locals as any)?.runtime?.env?.REVALIDATE_SECRET || process.env.REVALIDATE_SECRET;
if (expectedSecret && secret !== expectedSecret) {
return new Response(JSON.stringify({ error: 'Unauthorized handshake' }), { status: 401 });
}
// 2. Instant handshake probe for AstroPress admin dashboard
if (type === 'test' || action === 'ping' || slug === 'test-connection') {
return new Response(JSON.stringify({
success: true,
status: 'connected',
framework: 'Astro SSR on Cloudflare Edge',
timestamp: Date.now()
}), { status: 200 });
}
// 3. Resolve affected route paths
const affected: string[] = Array.isArray(urls) && urls.length > 0
? urls
: (slug ? ['/' + slug.replace(/^\//, '')] : ['/']);
if (!affected.includes('/')) affected.push('/');
// 4. Invalidate Cloudflare Worker caches.default in-memory store
try {
const cache = (globalThis as any).caches?.default;
if (cache) {
for (const u of affected) {
const targetUrl = new URL(u, request.url).href;
await cache.delete(new Request(targetUrl));
}
}
} catch (err) {
console.error('Worker cache delete error:', err);
}
// 5. Trigger Cloudflare Zone Cache API purge (<150ms)
const cfZoneId = (locals as any)?.runtime?.env?.CF_ZONE_ID || process.env.CF_ZONE_ID;
const cfApiToken = (locals as any)?.runtime?.env?.CF_API_TOKEN || process.env.CF_API_TOKEN;
const frontendUrl = (locals as any)?.runtime?.env?.FRONTEND_URL || process.env.FRONTEND_URL;
let cfPurged = false;
if (cfZoneId && cfApiToken && frontendUrl) {
try {
const purgeUrls = affected.map(u => new URL(u, frontendUrl).href);
const cfRes = await fetch(`https://api.cloudflare.com/client/v4/zones/${cfZoneId}/purge_cache`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${cfApiToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ files: purgeUrls })
});
cfPurged = cfRes.ok;
} catch (e) {
console.error('CF Zone Purge error:', e);
}
}
// 6. Pre-warm canonical routes to eliminate visitor cold boots
if (frontendUrl) {
for (const u of affected) {
fetch(new URL(u, frontendUrl).href, {
headers: { 'User-Agent': 'AstroPress-EdgeWarmer/2.5' }
}).catch(() => {});
}
}
return new Response(JSON.stringify({
success: true,
revalidated: true,
purged: affected,
cfPurged
}), {
status: 200,
headers: { 'Content-Type': 'application/json' }
});
}; Quickstart Setup Guide
Follow these simple steps to deploy AstroPress on your WordPress and Astro instances.
Download & Upload Companion Plugin
Download astropress.zip directly from the official GitHub Releases pipeline.
In your WordPress admin, go to Plugins > Add New Plugin > Upload Plugin, choose the zip file, and click Install Now.
1-Click Cloudflare Quick Connect
Navigate to AstroPress > Cloudflare R2 in your WordPress sidebar. Provide a scoped Cloudflare API Token; the plugin automatically discovers your Account ID, matching Zone ID, R2 buckets, and Pages projects in 1 click.
Configure Astro Frontend URL & Webhook Secret
In AstroPress > Headless Bridge, enter your production Astro frontend URL (e.g. https://example.com)
and define a secure REVALIDATE_SECRET token. Click Test Handshake to verify live edge connectivity.
Deploy Astro Edge Endpoint & Enjoy 5ms Page Loads
Add src/pages/api/revalidate.ts to your Astro project and deploy to Cloudflare Pages or Workers.
Every time you publish or update content in WordPress, your edge caches will invalidate and pre-warm in under 150ms.
Ready to Build with AstroPress?
Download the companion plugin or explore the open-source repository on GitHub.