avoid doing the same expensive work over and over again. 📖 A bookmark saving your place 🍕 Leftovers instead of cooking from scratch 🚀 A shortcut instead of taking the long route
1. Browser – User Requests the Site 2. Internet – DNS & Routing 3. Web Server – Receives the Request 4. PHP – WordPress Processing 5. Database Query (If Needed) 6. Response is Generated & Sent Back 7. The page loads 🥳
times – Nobody likes a slow website! • Cached pages load in milliseconds instead of running WordPress & database queries every time. Image baking a cake from scratch every time you want a slice
the number of requests hitting the server. • With caching: ◦ More visitors = Same fast response, lower server strain • Without caching: ◦ More visitors = More DB & PHP processing = Server overload Image a single cashier at the grocery store during the holiday season with no express of self-checkout lanes.
Less server processing = Lower hosting costs • Caching offloads work from higher server or hosting layers, CDN, Web server, PHP, DB) thus reducing resource usage. Image pre-cooking meals for the week instead of using fresh groceries daily.
short (Reminder) 1. Browser – User Requests the Site 2. Internet – DNS & Routing 3. Web Server – Receives the Request 4. PHP – WordPress Processing 5. Database Query (If Needed) 6. Response is Generated & Sent Back 7. The page loads 🥳
images, fonts. • Favicons – Your site’s little icon in the browser tab. • HTML (if configured) What Gets Cached? • Dynamic content – Things like cart pages, personalized data, or live updates. What does not? DNS caching • stores recently resolved domain-to-IP mappings
• If assets are cached for too long, users may not see updates unless the browser cache is cleared. 🔄 Cached Redirects Can Cause Problems: • If a redirect is cached, users may keep getting sent to an old URL, even after it’s changed. ◦ Solution: HTTP Headers: Cache-Control: no-store for temporary redirects.
Be Cached: • Login, account dashboards, and checkout pages should never be stored in the browser cache. ◦ Solution: HTTP headers: Cache-Control: private, no-cache, no-store, must-revalidate. 📱 Mobile Browsers Cache Differently: • Some mobile browsers may cache more aggressively than desktop browsers. ◦ Solution: Test across devices/browsers to ensure proper caching behavior.
If content updates but the CDN keeps serving an old version, users may see outdated pages. ◦ Solution: Cache purge process – automated is best* 🌎 Geographic Differences • A CDNs may cache more aggressively than others in certain regions. ◦ Solution: Set proper TTL and cache rules.
Cached at a CDN’s edge servers for global fast delivery • Example: Cloudflare, Fastly. Server-Level Page Caching • Handled directly by the hosting environment before WordPress runs • Example: Nginx FastCGI, Varnish Plugin-Level Page Caching • Caching done within WordPress using plugins • Example: WP Rocket, Perfmatters, W3 Total Cache Types of Page Caching
Static assets • API responses (sometimes) What Gets Cached? • Personalized or dynamic content – Logged-in user dashboards, shopping carts, user-specific pages. • Forms and interactive elements ◦ Feeds, search results • Checkout & payment pages • Admin pages What does not?
If content updates but the CDN keeps serving an old version, users may see outdated pages. ◦ Solution: Cache purge process – automated is best* ⚠ Dynamic Pages Need Exclusions – Login pages, carts, and personalized content should not be cached …unless fragment caching is configured…but what’s that??
page, only certain sections are cached. ◦ Cached fragments stay fast (menus, footers). ◦ Dynamic sections stay fresh and don’t get cached. Fragment Caching • Menus & navigation bars • Footers & static widgets • Product listings • Popular blog post lists What May be Cached? ⚠ Requires proper meticulous implementation ⚠ Not as simple as full page caching. ⚠ Service dependent. Beware!
1. Reads the PHP file 2. Compiles it into machine code 3. Executes the code Without OPCache • The compiled PHP code is stored in memory and reused. • No need to recompile the same script on every request. With OPCache
PHP Code Issues – If the code changes, OPcache may still serve the old version until cleared. ⚠ Requires Sufficient Memory – More caching means more RAM usage. ⚠ Not a Full-Page Cache – Only improves PHP execution, doesn’t replace page/object caching.
• Stores query results directly in MySQL’s memory. • No longer recommended due to efficiency issues. Redis/Memcached for Query Caching – Persistent Object Caching • Queries are stored in RAM, significantly improving performance. • Used by managed hosts & advanced setups. WordPress Transients (Soft Query Caching) • WordPress stores temporary query results in the database. • Works well for caching API responses or dynamic content. Types of Database Query Caching
◦ fetching product data, user lists, reports • Repeated queries across multiple users • API responses stored as transients What Gets Cached? • Constantly changing data ◦ live order processing, stock levels • Per-user queries (unless configured) What does not?
database queries benefit from caching – Some are too small to make a difference. ⚠ Can cause stale data issues – Cached queries must be invalidated when data updates.
Stack Experience - Takeaways • Each caching layer plays a role in reducing load, improving speed, and scaling efficiently. • Together, they form a complete caching strategy. Too many cache layers can cause conflicts so balance is key. • Invalidation matters! A stale cache can be worse than no cache! • Caching makes WordPress faster, more scalable, and efficient.