0Pricing
Caching Strategies: Redis + CDN + Edge Computing · บทเรียน

กลยุทธ์การทำให้แคชไม่ถูกต้องและการล้างแคช

เชี่ยวชาญเทคนิคการลบหรือรีเฟรชเนื้อหาเก่าจากแคช ได้แก่ การล้างตาม URL ตามแท็ก การล้างแบบนุ่มนวลเทียบกับแบบสมบูรณ์ และข้อแลกเปลี่ยนของแต่ละวิธี

กลยุทธ์การทำให้แคชไม่ถูกต้องและการล้างแคช เป็นบทเรียน Caching Strategies: Redis + CDN + Edge Computing ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Caching Strategies: Redis + CDN + Edge Computing และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Caching Strategies: Redis + CDN + Edge Computing มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Invalidation Is Hard

There is a famous saying that one of the two hard things in computing is cache invalidation. The challenge is removing stale content everywhere it lives without harming performance.

  • Content is replicated across many edge locations
  • Removing too aggressively kills your hit ratio
  • Removing too little serves stale data

Purge by Single URL

The simplest purge targets one exact URL. Fast and precise, but tedious when many related objects change at once.

curl -X POST "https://api.cdn.com/purge" -d "url=/images/logo.png"

Purge by Prefix or Path

Purging by prefix clears everything under a path, like all files in /assets/v3/. Useful after deploying a directory of changed assets.

Surrogate Keys and Tag-Based Purge

Tag-based purging attaches labels (surrogate keys) to responses, then purges everything sharing a tag in one call. Perfect for invalidating all pages that reference a changed product.

Surrogate-Key: product-42 category-shoes

Wildcard and Full Purge

A full purge clears the entire cache. It is a blunt instrument: it guarantees freshness but causes a temporary surge of origin traffic as everything re-fills. Reserve it for emergencies.

Soft Purge vs Hard Purge

Hard purge deletes content immediately. Soft purge marks it stale so the edge can still serve it while revalidating, smoothing the origin load.

  • Hard: instant removal, possible miss storm
  • Soft: graceful refresh, slight staleness window

Versioned URLs Instead of Purging

Often the best invalidation is to not invalidate at all. Embed a version or hash in the asset URL so new content gets a new key and old caches simply age out.

app.[contenthash].js  ->  app.9f2a1c.js

Propagation Time

Purges are not always instant. They propagate across PoPs over seconds. Plan deploys so users do not see a mix of old and new assets during the window.

Invalidation Across Layers

In a Redis plus CDN stack, a write must invalidate the right layers. Deleting a Redis key alone will not clear a CDN edge copy; coordinate purges across both.

redis-cli DEL user:42:profile
# also issue CDN purge for /api/users/42

Automating Purge in CI/CD

Wire purges into your deploy pipeline so the right tags or paths are cleared automatically after each release, avoiding manual, error-prone purging.

Choosing a Strategy

Match the tool to the change:

  • One file changed: purge by URL
  • A directory deployed: purge by prefix
  • Related content across pages: tag-based purge
  • Frequent asset changes: versioned URLs (no purge)
  • Emergency only: full purge

Quick Check

Test your invalidation knowledge.

Recap

You learned cache invalidation strategies: purge by URL, prefix, or surrogate-key tag; soft versus hard purge; full purge as a last resort; and avoiding purges entirely with versioned URLs. You also saw how to coordinate invalidation across cache layers and automate it in CI/CD.

คำถามที่พบบ่อย

บทเรียน “กลยุทธ์การทำให้แคชไม่ถูกต้องและการล้างแคช” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “กลยุทธ์การทำให้แคชไม่ถูกต้องและการล้างแคช” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Caching Strategies: Redis + CDN + Edge Computing ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Caching Strategies: Redis + CDN + Edge Computing มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “กลยุทธ์การทำให้แคชไม่ถูกต้องและการล้างแคช”

เชี่ยวชาญเทคนิคการลบหรือรีเฟรชเนื้อหาเก่าจากแคช ได้แก่ การล้างตาม URL ตามแท็ก การล้างแบบนุ่มนวลเทียบกับแบบสมบูรณ์ และข้อแลกเปลี่ยนของแต่ละวิธี คุณปฏิบัติ Caching Strategies: Redis + CDN + Edge Computing ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Caching Strategies: Redis + CDN + Edge Computing หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Caching Strategies: Redis + CDN + Edge Computing บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน

บทเรียน “กลยุทธ์การทำให้แคชไม่ถูกต้องและการล้างแคช” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Caching Strategies: Redis + CDN + Edge Computing นี้ได้ไหม

ได้ บทเรียน Caching Strategies: Redis + CDN + Edge Computing ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การล้างแคชและการกำหนดเวอร์ชัน
  2. การเฝ้าติดตามอัตราการพบข้อมูลในแคช
  3. การแก้ไขปัญหาแคช
  4. กลยุทธ์การทำให้แคชไม่ถูกต้องและการล้างแคช
← กลับไปที่ Caching Strategies: Redis + CDN + Edge Computing