SlideShare a Scribd company logo
Caching  Strategies Michal Špaček, Skype;  WebExpo 2011 , Prague @spazef0rze, www.michalspacek.cz
What the...  Cache ? HDD cache, CPU cache, DNS cache, web cache, geocache
What the...  Cache ? HDD cache, CPU cache, DNS cache,  web cache , geocache
CLIENT (BROWSER) WEB SERVER DATABASE SERVER
HTTP level caching
Client local disk/memory cache CLIENT (BROWSER) WEB SERVER
Response headers: Expires Last-Modified ETag Cache-Control Pragma CLIENT (BROWSER) WEB SERVER
Expires:  HTTP-date Expires: Sat, 24 Sep 2011 12:00:00 GMT <  Expires CLIENT (BROWSER)
Expires:  HTTP-date Expires: Sat, 24 Sep 2011 12:00:00 GMT >  Expires CLIENT (BROWSER) WEB SERVER
Last-Modified:  HTTP-date Following request: If-Modified-Since:  HTTP-date
Last-Modified:  HTTP-date Following request: If-Modified-Since:  HTTP-date Response: Entity modified:  HTTP 200 OK Not modified:  HTTP 304 Not Modified
Last-Modified:  HTTP-date Saves bandwidth!
ETag:  quoted-string Following request: If-None-Match:  quoted-string
ETag:  quoted-string Following request: If-None-Match:  quoted-string Response: No match :  HTTP 200 OK A match:  HTTP 304 Not Modified
Saves bandwidth, too! ETag:  quoted-string
If-Modified-Since If-Unmodified-Since If-None-Match If-Match
ETag  ×  Last-Modified hash (GUID)  ×  HTTP-date (seconds)
ETag  ×  Last-Modified hash (GUID)  ×  HTTP-date (seconds) weak+strong validation  ×  strong
ETag  ×  Last-Modified hash (GUID)  ×  HTTP-date (seconds) weak+strong validation  ×  strong needs content  ×  needs date
Request+Response header Cache-Control:  whatever
Request+Response header whatever =  max-age ,  no-cache ,  public ,  must-revalidate  (response only),  ... Cache-Control:  whatever
Pragma:  no-cache Request+Response header
Pragma:  no-cache Request+Response header Request: HTTP 1.0 variant of Cache-Control: no-cache
Pragma:  no-cache Request+Response header Request: HTTP 1.0 variant of Cache-Control: no-cache Response: meaning undefined, wtf
Proxy cache CLIENT (BROWSER) WEB SERVER
Proxy cache CLIENT (BROWSER) WEB SERVER
Application level caching
Configuration Does not change often
Configuration Does not change often Parse (files)/read (from db) and store to  APC
APC:  The Alternative PHP Cache PHP extension Data store (also opcode cache)
APC:  The Alternative PHP Cache Data persist between requests
APC:  The Alternative PHP Cache Data persist between requests … until deleted or cache cleared or server restarted
Database connection cache Persistent connections (don't work) Connection pooler
Database query cache Some systems have query cache
Database query cache Some systems have query cache Some don't
Result set cache Some data don't change
Result set cache Some data don't change Fetch and store to  memcached
Memcached Client-server architecture Key-value in memory store for strings and objects
Problems with caching
Data change sometimes but not often enough Employee list of a company
Data change sometimes but not often enough Employee list of a company Invalidate cache when adding or removing employees
Data change sometimes and delay is okay Translations from database
Data change sometimes and delay is okay Translations from database Introduce cache lifetime
Moar cache keys for the same data Sorted employee list (asc, desc)
Moar cache keys for the same data Sorted employee list (asc, desc) Cache groups
Cache groups Keys: list-sorted-asc, list-sorted-desc
Cache groups Keys: list-sorted-asc, list-sorted-desc Group „list“: list-sorted-asc, list-sorted-desc, list-unsorted
Cache groups Keys: list-sorted-asc, list-sorted-desc Group „list“: list-sorted-asc, list-sorted-desc, list-unsorted Delete group „list“ when adding/removing
Cache wherever and whatever
…  but delete your whatever when needed
Caching is magic
Caching is magic but not automagic
Caching is magic but not automagic until now
www.phpguru.cz/kaskadova-cache 2010 © Skype – As seen on TV Slide
Practical implementation, anyone ? 2010 © Skype – As seen on TV Slide
Thanks for listening Michal Špaček, @spazef0rze BTW, love caching? skypecareers.com!

More Related Content

PPTX
Caching
PPTX
Understanding Web Cache
PPTX
AWS IAM and security
PDF
AWS AutoScaling
PPTX
Apache Kafka Architectures and Fundamentals
PDF
Amazon Aurora Deep Dive (김기완) - AWS DB Day
PPT
OpenSearch
PPTX
Understanding the Windows Server Administration Fundamentals (Part-1)
Caching
Understanding Web Cache
AWS IAM and security
AWS AutoScaling
Apache Kafka Architectures and Fundamentals
Amazon Aurora Deep Dive (김기완) - AWS DB Day
OpenSearch
Understanding the Windows Server Administration Fundamentals (Part-1)

What's hot (20)

PPTX
Ajax
PPTX
AWS S3 | Tutorial For Beginners | AWS S3 Bucket Tutorial | AWS Tutorial For B...
PPTX
PySpark dataframe
PDF
AWS S3 and GLACIER
PDF
Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...
PPTX
Introduction to Storm
PDF
Cassandra at Instagram (August 2013)
PDF
Log Structured Merge Tree
PPTX
Debugging .NET apps
PDF
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
PDF
실시간 스트리밍 분석 Kinesis Data Analytics Deep Dive
PPTX
AWS Cloud trail
PPT
Step-by-Step Introduction to Apache Flink
PDF
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
PDF
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
PDF
워크로드 특성에 따른 안전하고 효율적인 Data Lake 운영 방안
PDF
Using Apache Spark to Solve Sessionization Problem in Batch and Streaming
PDF
AWS 클라우드 서비스 소개 및 사례 (방희란) - AWS 101 세미나
PPTX
NoSQL databases - An introduction
PPTX
Data Guard Architecture & Setup
Ajax
AWS S3 | Tutorial For Beginners | AWS S3 Bucket Tutorial | AWS Tutorial For B...
PySpark dataframe
AWS S3 and GLACIER
Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...
Introduction to Storm
Cassandra at Instagram (August 2013)
Log Structured Merge Tree
Debugging .NET apps
Amazon DocumentDB vs MongoDB 의 내부 아키텍쳐 와 장단점 비교
실시간 스트리밍 분석 Kinesis Data Analytics Deep Dive
AWS Cloud trail
Step-by-Step Introduction to Apache Flink
Accelerating Apache Spark Shuffle for Data Analytics on the Cloud with Remote...
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
워크로드 특성에 따른 안전하고 효율적인 Data Lake 운영 방안
Using Apache Spark to Solve Sessionization Problem in Batch and Streaming
AWS 클라우드 서비스 소개 및 사례 (방희란) - AWS 101 세미나
NoSQL databases - An introduction
Data Guard Architecture & Setup
Ad

Similar to Caching Strategies (20)

PDF
Less and faster – Cache tips for WordPress developers
KEY
Site Performance - From Pinto to Ferrari
PPT
Scaling 101
PPT
Scaling 101 test
ODP
Caching and tuning fun for high scalability
PPT
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
PDF
Application Scalability in Server Farms - NCache
PPT
Four Ways to Improve ASP .NET Performance and Scalability
PDF
Static analysis saved my code tonight
ODP
Caching and tuning fun for high scalability @ phpBenelux 2011
ODP
Caching and tuning fun for high scalability
PPTX
Share point 2013 distributed cache
PPTX
Advanced HTTP Caching
ODP
Clug 2011 March web server optimisation
PDF
Building a high-performance data lake analytics engine at Alibaba Cloud with ...
ODP
Caching and tuning fun for high scalability
ODP
MNPHP Scalable Architecture 101 - Feb 3 2011
PDF
Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
ODP
Caching and tuning fun for high scalability @ FOSDEM 2012
ODP
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Less and faster – Cache tips for WordPress developers
Site Performance - From Pinto to Ferrari
Scaling 101
Scaling 101 test
Caching and tuning fun for high scalability
Varnish and Drupal- Accelerating Website Performance and Flexibility with Var...
Application Scalability in Server Farms - NCache
Four Ways to Improve ASP .NET Performance and Scalability
Static analysis saved my code tonight
Caching and tuning fun for high scalability @ phpBenelux 2011
Caching and tuning fun for high scalability
Share point 2013 distributed cache
Advanced HTTP Caching
Clug 2011 March web server optimisation
Building a high-performance data lake analytics engine at Alibaba Cloud with ...
Caching and tuning fun for high scalability
MNPHP Scalable Architecture 101 - Feb 3 2011
Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
Caching and tuning fun for high scalability @ FOSDEM 2012
Как Web-акселератор акселерирует ваш сайт / Александр Крижановский (Tempesta ...
Ad

More from Michal Špaček (20)

ODP
Víceúrovňová obrana vysvětlená na Cross-Site Scriptingu
ODP
Lámání a ukládání hesel
ODP
Fantom Opery, "VPN" a Secure Proxy v Opeře
ODP
Quality of Life, Multiple Lines of Defense
ODP
Jak zlepšit zabezpečení čtvrtiny celého webu
ODP
Medvědí služba
ODP
Disclosing password hashing policies
ODP
XSS PHP CSP ETC OMG WTF BBQ
ODP
Bezpečnost e-shopů (HTTPS, XSS, CSP)
ODP
Poučte se z cizích chyb
ODP
Minulé století volalo (Cross-Site Scripting + BeEF + CSP demo)
ODP
Password manažeři detailněji – 1Password, LastPass, 2FA, sdílení
ODP
Operations security (OPSEC) in IT
ODP
HTTPS (a šifrování) všude
ODP
HTTP Strict Transport Security (HSTS), English version
ODP
Bezpečnost na mobilních zařízeních
ODP
Základy webové bezpečnosti pro PR a marketing
ODP
I forgot my password – what a secure password reset needs to have and why
ODP
Hlava není na hesla
ODP
HTTP Strict Transport Security (HSTS)
Víceúrovňová obrana vysvětlená na Cross-Site Scriptingu
Lámání a ukládání hesel
Fantom Opery, "VPN" a Secure Proxy v Opeře
Quality of Life, Multiple Lines of Defense
Jak zlepšit zabezpečení čtvrtiny celého webu
Medvědí služba
Disclosing password hashing policies
XSS PHP CSP ETC OMG WTF BBQ
Bezpečnost e-shopů (HTTPS, XSS, CSP)
Poučte se z cizích chyb
Minulé století volalo (Cross-Site Scripting + BeEF + CSP demo)
Password manažeři detailněji – 1Password, LastPass, 2FA, sdílení
Operations security (OPSEC) in IT
HTTPS (a šifrování) všude
HTTP Strict Transport Security (HSTS), English version
Bezpečnost na mobilních zařízeních
Základy webové bezpečnosti pro PR a marketing
I forgot my password – what a secure password reset needs to have and why
Hlava není na hesla
HTTP Strict Transport Security (HSTS)

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
KodekX | Application Modernization Development
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
cuic standard and advanced reporting.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Programs and apps: productivity, graphics, security and other tools
MYSQL Presentation for SQL database connectivity
KodekX | Application Modernization Development
“AI and Expert System Decision Support & Business Intelligence Systems”
Understanding_Digital_Forensics_Presentation.pptx
cuic standard and advanced reporting.pdf
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Chapter 3 Spatial Domain Image Processing.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Reach Out and Touch Someone: Haptics and Empathic Computing
Programs and apps: productivity, graphics, security and other tools

Caching Strategies

Editor's Notes

  • #3: Q: Kdo víte, co je to cache? ME: cache je rychlé úložiště, kam s ukládají data z pomalého úložiště Q: kdo si myslí, že jsem to řekl špatně? Me: popovídáme si potom Q: kdo používáte nějakou cache? Me: všichni
  • #5: Ukázkový model
  • #7: Co znamená cache, jak se chová klient, v nejlepším případě neodejde žádný požadavel na server
  • #8: Když odejde, server vrátí v odpovědi tyto hlavičky
  • #17: Hlavičky pro podmíněné dotazy mají obrácené varianty
  • #22: Má spoustu parametrů, tohle jsou nejzajímavější, zbytek by vydal na druhou přednášku
  • #27: V ideálním případě odpovídá cache, ne půvvodní server
  • #36: Víc se toho říct nedá, to je taky na samostatnou přednášku
  • #51: ...Což není tak jednoduchý, protože
  • #55: Největší teoretik v čechách napsal článek, návrh, jak to celý zautomatizovat, problém je ten, že existuje snad jen jeden člověk, který to dokáže prakticky napsat.