SlideShare a Scribd company logo
Submit Search
Upload
Login
Signup
Caching on the web
Report
Jean Carlo Emer
Follow
Senior Developer at Work & Co
May. 18, 2017
•
0 likes
•
390 views
1
of
80
Caching on the web
May. 18, 2017
•
0 likes
•
390 views
Download Now
Download to read offline
Report
Technology
This talk covers one of the secrets of high scalability and performance.
Jean Carlo Emer
Follow
Senior Developer at Work & Co
Recommended
World Wide Web Caching
ersanbilik
2.1K views
•
21 slides
Understanding Web Cache
ProdigyView
2.9K views
•
15 slides
Caching Strategies
Michal Špaček
11.7K views
•
56 slides
Building low latency java applications with ehcache
Chris Westin
4.2K views
•
41 slides
Rest services caching
Sperasoft
6.6K views
•
28 slides
WordPress at Peak Performance (Radio Edit)
jaredwsmith
1.5K views
•
24 slides
More Related Content
What's hot
Caching
saravanan_k83
312 views
•
23 slides
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Felix Gessert
8.4K views
•
67 slides
Implementing High Performance Drupal Sites
Shri Kumar
3.1K views
•
14 slides
Ui perf
Franz Allan See
1.2K views
•
20 slides
How to reduce database load using Memcache
valuebound
21K views
•
11 slides
23 Ways To Speed Up WordPress
Zero Point Development
138 views
•
39 slides
What's hot
(20)
Caching
saravanan_k83
•
312 views
Building a Global-Scale Multi-Tenant Cloud Platform on AWS and Docker: Lesson...
Felix Gessert
•
8.4K views
Implementing High Performance Drupal Sites
Shri Kumar
•
3.1K views
Ui perf
Franz Allan See
•
1.2K views
How to reduce database load using Memcache
valuebound
•
21K views
23 Ways To Speed Up WordPress
Zero Point Development
•
138 views
High Performance Drupal
Chapter Three
•
2.8K views
Roshan Bhattarai: Scaling WordPress for high traffic sites
wpnepal
•
2.4K views
Scaling wordpress for high traffic
Roshan Bhattarai
•
1.9K views
WordPress Need For Speed
pdeschen
•
1.2K views
Caching for J2ee Enterprise Applications
Debajani Mohanty
•
5.7K views
WordPress At Scale. WordCamp Dhaka 2019
Anam Ahmed
•
334 views
Drupal performance optimization Best Practices
Ratnesh kumar, CSM
•
3.8K views
Rails Caching: Secrets From the Edge
Fastly
•
2.6K views
5 Reasons to Upgrade Ehcache to BigMemory Go
Terracotta, a product line at Software AG
•
6.6K views
Browser Caching
Jaiswal Siddharth
•
35 views
Accelerating Rails with edge caching
Michael May
•
1K views
Memcached Presentation
Asif Ali
•
2.8K views
Performance Optimization using Caching | Swatantra Kumar
Swatantra Kumar
•
62 views
Caching: A Guided Tour - 10/12/2010
Jason Ragsdale
•
451 views
Similar to Caching on the web
Scale Your Data Tier with Windows Server AppFabric
Wim Van den Broeck
691 views
•
53 slides
Web site optimization
Sunil Patil
297 views
•
51 slides
Web Site Optimization
Sunil Patil
2.4K views
•
51 slides
Caching By Nyros Developer
Nyros Technologies
786 views
•
27 slides
Mini-Training: To cache or not to cache
Betclic Everest Group Tech Team
3.3K views
•
25 slides
Nginx Scalable Stack
Bruno Paiuca
221 views
•
40 slides
Similar to Caching on the web
(20)
Scale Your Data Tier with Windows Server AppFabric
Wim Van den Broeck
•
691 views
Web site optimization
Sunil Patil
•
297 views
Web Site Optimization
Sunil Patil
•
2.4K views
Caching By Nyros Developer
Nyros Technologies
•
786 views
Mini-Training: To cache or not to cache
Betclic Everest Group Tech Team
•
3.3K views
Nginx Scalable Stack
Bruno Paiuca
•
221 views
Clug 2011 March web server optimisation
grooverdan
•
264 views
cache concepts and varnish-cache
Marc Cortinas Val
•
1.8K views
Oracle UCM: Web Site Performance Tuning
Brian Huff
•
6.6K views
Jax Ajax Architecture
Alois Reitbauer
•
890 views
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
Amazon Web Services
•
4.4K views
21 Www Web Services
royans
•
4.1K views
Day 7 - Make it Fast
Barry Jones
•
892 views
Application Scalability in Server Farms - NCache
Alachisoft
•
2.1K views
AWS re:Invent 2016: Amazon CloudFront Flash Talks: Best Practices on Configur...
Amazon Web Services
•
2.2K views
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
Fwdays
•
253 views
Content Caching with NGINX and NGINX Plus
Kevin Jones
•
1.5K views
Cdn technology overview
Yoohyun Kim
•
93 views
Rails Caching Secrets from the Edge
Michael May
•
1.7K views
W-JAX Performance Workshop - Web and AJAX
Alois Reitbauer
•
592 views
Recently uploaded
Navigating the Future
OnBoard
24 views
•
48 slides
Improving Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft ...
ThousandEyes
63 views
•
25 slides
Mitigating Third-Party Risks: Best Practices for CISOs in Ensuring Robust Sec...
TrustArc
42 views
•
21 slides
Future of Skills
Alison B. Lowndes
38 views
•
50 slides
Keynote: Two years at the British Library... and counting / Alan Danskin (Bri...
CILIP MDG
24 views
•
33 slides
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
NicolasVuillamy1
186 views
•
39 slides
Recently uploaded
(20)
Navigating the Future
OnBoard
•
24 views
Improving Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft ...
ThousandEyes
•
63 views
Mitigating Third-Party Risks: Best Practices for CISOs in Ensuring Robust Sec...
TrustArc
•
42 views
Future of Skills
Alison B. Lowndes
•
38 views
Keynote: Two years at the British Library... and counting / Alan Danskin (Bri...
CILIP MDG
•
24 views
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
NicolasVuillamy1
•
186 views
Experts Live Europe 2023 - Ensure your compliance in Microsoft Teams with Mic...
Jasper Oosterveld
•
56 views
Die ultimative Anleitung für HCL Nomad Web Administratoren
panagenda
•
57 views
Metadata & Discovery Group Conference 2023 - Day 2
CILIP MDG
•
14 views
ISO Survey 2022: ISO 27001 certificates (ISMS)
Andrey Prozorov, CISM, CIPP/E, CDPSE. LA 27001
•
79 views
Demystifying ML/AI
Matthew Reynolds
•
29 views
Supplier Sourcing_Cathy.pptx
CatarinaTorrenuevaMa
•
15 views
web test repair.pptx
YuanzhangLin
•
25 views
Scaling out with WordPress
Konstantin Kovshenin
•
54 views
Nymity Framework: Privacy & Data Protection Update in 7 States
TrustArc
•
123 views
Accelerating Data Science through Feature Platform, Transformers, and GenAI
FeatureByte
•
139 views
Netwitness RT - Don’t scratch that patch.pptx
Stefano Maccaglia
•
92 views
Swiss Re Reinsurance Solutions - Automated Claims Experience – Insurer Innova...
The Digital Insurer
•
30 views
Knowledge graph use cases in natural language generation
Elena Simperl
•
84 views
Common WordPress APIs - Options API
Jonathan Bossenger
•
19 views
Caching on the web
1.
Cachingon the web @jcemer
2.
jcemer.com twitter.com/jcemer
4.
Cache is a
hardware or software component that stores data so future requests for that data can be served faster - Wikipedia
5.
Caching and RAM is
the answer to everything - about Flickr Architecture
6.
Caching is one
of the secrets of high scalability and performance
7.
Where could cache
be present on the web? • Browser • Network • Server • Application
8.
Browsercaching
9.
Caching would be useless
if it did not significantly improve performance - HTTP/1.1 specification
10.
The user might reuse
assets during navigation
11.
• Documents • Images •
Scripts and CSS • Asynchronous Requests What could be cached?
12.
HTTP headers have
the responsibility to define if a response could be cached and for how long
13.
GET /main.css HTTP/1.1 Host:
jcemer.com
14.
GET /main.css HTTP/1.1 Host:
jcemer.com HTTP/1.1 200 Date: Tue, 13 Sep 2016 13:32:50 GMT Cache-Control: max-age=604800 <Response Data>
15.
allows the response
to be stored in cache Cache-Control: max-age=604800 Response header
16.
CSS is requested
once during navigation 😄 😄
17.
The browser requests
it again only if the cache expires or if the user force refreshes the page
18.
allow to add
more info about the resource Last-Modified: Mon, 12 Sep 2016 22:06:39 GMT Etag: W/"337e7-8HrLmYe6UGIUDolQeGLoyw" Response headers
19.
GET /main.css HTTP/1.1 Host:
jcemer.com HTTP/1.1 200 OK Date: Tue, 13 Sep 2016 13:32:50 GMT Last-Modified: Mon, 12 Sep 2016 15:23:17 GMT Cache-Control: max-age=604800 new
20.
allow reuse the
cached resource if it didn’t change If-Modified-Since: Mon, 12 Sep 2016 15:23:17 GMT If-Match: W/"337e7-8HrLmYe6UGIUDolQeGLoyw" Request headers
21.
GET /main.css HTTP/1.1 Host:
jcemer.com If-Modified-Since: Mon, 12 Sep 2016 15:23:17 GMT
22.
GET /main.css HTTP/1.1 Host:
jcemer.com If-Modified-Since: Mon, 12 Sep 2016 15:23:17 GMT HTTP/1.1 304 Not Modified Date: Tue, 13 Sep 2016 13:32:50 GMT Cache-Control: max-age=604800 HTTP/1.1 200 OK Date: Tue, 13 Sep 2016 13:32:50 GMT Last-Modified: Mon, 12 Sep 2016 15:23:17 GMT <Response Data> <No Response Data>
23.
A Website with
the HTTP headers wisely defined will provide a better experience for the users
24.
Networkcaching
25.
Content Delivery Network (CDN)
is a globally distributed network of proxy servers - Wikipedia
26.
allows proxy servers to
cache the content Cache-control: public
27.
Servercaching
28.
Finally, the control is
all on your hand, developer!
29.
Cache server
30.
The cache server
stay between the user and the application or other servers
31.
• Shared documents •
Images • Scripts and CSS • Asynchronous Requests What could be cached?
32.
• Varnish • Squid •
nginx Tools https://varnish-cache.org http://www.squid-cache.org https://www.nginx.com
33.
location / { proxy_pass
http://otherserver; } the nginx intermediates the client request’s
34.
nginx cache server
35.
proxy_cache_path /path/to/cache; location /
{ proxy_pass http://otherserver; proxy_cache cache; } caching!
36.
😄 nginx cache server
37.
The proxy caches content
relying only on the application HTTP headers
38.
t1 t2 t1 request at a different
time
39.
😓 … t1 t1 t1 x3
40.
proxy_cache_lock on; proxy_cache_lock_timeout 180; allow
the proxy to delegate only the first of similar requests at a time
41.
t1 t1 😄x1
42.
All clients are
waiting until receive the response when the first request returns
43.
What happen in case
of failures? 🤒
44.
allows to delivery
expired content in case of failure proxy_cache_use_stale timeout error http_500;
45.
😄 🤒
46.
The proxy could improve
the fault tolerance of the application
47.
proxy_cache_use_stale updating; delivers expired
content for the subsequent similar requests
48.
Appcaching
49.
Caching on the
app reduces the time of specific operations
50.
• Complex computations •
Data shared across requests What could be cached?
51.
def price @price ||=
Price.new(unit_price, category) end
52.
Memoization stores the results
to avoid future calculations
53.
A global code memoization
is going to last in-memory during all the application execution cycle
54.
$price = Price.new(unit_price,
category) 😓
55.
cache.fetch("cat#{cat_id}", expires_in: 1.minute)
do CatagoryTax.new(cat_id) end http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html ActiveSupport::Cache::Store
56.
Rails Caching API allows
store and reuse data during an amount of time across requests
57.
https://github.com/ptarjan/node-cache/issues/77 😓
58.
🔥
59.
Rails Memory Caching wisely
prunes the cached data when it exceeds the allotted memory size
60.
One of the
ways to scale an application is through adding more application instances (scale horizontally) 😓
62.
Load balancer App instances
63.
Never assumes that anything
cached in memory or on disk will be available on a future request https://12factor.net/processes
64.
Any storage could
be used to share cache data between instances but the Key-value Storages are the most common
65.
• Redis • Memcached Key-value
Storages http://redis.io http://memcached.org
67.
These tools have different
policies to prune the amount of cached data
68.
Cache Storages might
also be fault tolerable with replication and persistence http://redis.io/topics/persistence http://redis.io/topics/replication http://redis.io/topics/sentinel
70.
Race condition happens when
different application instances fetch for a not cached data at the same time 😓
71.
expired data! 😁
72.
cache.fetch(key, race_condition_ttl: 10.seconds)
do heavy_db_computation end http://api.rubyonrails.org/classes/ActiveSupport/Cache/Store.html ActiveSupport::Cache::Store
73.
😁 😳
74.
It is difficult
to completely eliminate cache updating race conditions issues with multiple application instances
75.
A solution for
that is to update the cache data outside the application flow and just consume cached data on the application
76.
1. Obey the HTTP
headers
77.
2. Caching is important
78.
3. Measure the miss/hits
of the caching strategy
79.
4. Evaluate carefully the
caching strategy options
80.
Thanks!@jcemer