CDN for PHP

Move repeated image, script and stylesheet requests to the edge. Set explicit rules for anonymous HTML and exclude session-dependent PHP responses.

Example cache policy
Public, cacheable resource
/static/site.92dc.css
Bypass shared cache
/account.php

Cache public resources from a PHP application

Cache static files at Cloud CDN. Cache anonymous PHP GET output where it is safe. Bypass admin, sessions and POST. Use Origin Shield on misses.

Assets off PHP-FPM

The edge can serve fresh CSS, JavaScript, fonts and images without invoking PHP.

Anonymous PHP from cache

Public pages that do not vary on session can be stored at the edge.

Origin Shield in front of PHP

Duplicate misses are consolidated before they reach the origin.

Configuration

Cloud CDN overview
  1. Put the document root behind Cloud CDN

    Pull the PHP origin over HTTPS.

  2. Cache static extensions first

    Start with css, js, images and fonts, then consider HTML.

  3. Bypass admin and POST

    Do not cache login, dashboards or form posts.

  4. Enable Origin Shield

    Protect PHP-FPM from thundering herds after TTL expiry.

Operational outcomes

  • Static files never need PHP
  • Anonymous pages can be cached
  • Origin Shield protects workers
  • Admin remains dynamic

Frequently asked questions

Does this work with Laravel, WordPress and custom PHP?

Yes. Those are PHP origins. See the dedicated WordPress and Laravel pages for framework-specific notes.

How should I set PHP session pages?

Bypass cache when the response depends on a session cookie.

Can I cache FastCGI output?

Cloud CDN caches the HTTP response. FastCGI remains an origin detail.

What about PHP built-in server?

Use a production origin such as nginx + PHP-FPM, not the built-in server.