Slide 1

Slide 1 text

WHAT IS CACHING? AND WHY DOES IT HATE ME?

Slide 2

Slide 2 text

3,485,250 23,235 = ?

Slide 3

Slide 3 text

cache, noun, \’kash\ In computing, a cache is a high-speed data storage layer which stores a subset of data, typically transient in nature, so that future requests for that data are served up faster than is possible by accessing the data’s primary storage location. Caching allows you to efficiently reuse previously retrieved or computed data.

Slide 4

Slide 4 text

3,485,250 23,235 = ?

Slide 5

Slide 5 text

3,485,250 23,235 = 150

Slide 6

Slide 6 text

Basically, it’s just an address book of pre- calculated data. A value is stored under a key (jargon alert: key/val store) so that it can be quickly referenced later.

Slide 7

Slide 7 text

Key Value username jessica 64 x 16 1024 124^12 1.3124788 price $52.65 Basically, it’s just an address book of pre- calculated data. A value is stored under a key (jargon alert: key/val store) so that it can be quickly referenced later.

Slide 8

Slide 8 text

IT’S NOT JUST A CONVENIENCE.

Slide 9

Slide 9 text

THE INTERNET WOULD NOT FUNCTION WITHOUT HEAVY USE OF CACHING.

Slide 10

Slide 10 text

TYPICAL WEB APPLICATION CACHING

Slide 11

Slide 11 text

TYPICAL CACHING SOURCES IN WEB APPLICATIONS ▸ Browser cache ▸ Web server cache CACHING: TYPICAL WEB APPLICATION CACHING

Slide 12

Slide 12 text

TYPICAL CACHING SOURCES IN WEB APPLICATIONS ▸ Browser cache ▸ Web server cache THAT’S IT RIGHT? CACHING: TYPICAL WEB APPLICATION CACHING

Slide 13

Slide 13 text

TYPICAL CACHING SOURCES IN WEB APPLICATIONS ▸ Browser cache ▸ Web server cache THAT’S IT RIGHT? NOT EVEN CLOSE CACHING: TYPICAL WEB APPLICATION CACHING

Slide 14

Slide 14 text

TYPICAL CACHING SOURCES IN WEB APPLICATIONS ▸ DNS Cache (on user’s computer) ▸ Browser assets cache (on user’s computer) ▸ Browser network requests cache (on user’s computer) ▸ DNS cache (on DNS server) ▸ Web server requests cache (on website’s server) ▸ Database records cache in web application (on website’s server) ▸ Database query cache in database (on website’s database server) ▸ CDN cache (on website’s CDN server) CACHING: TYPICAL WEB APPLICATION CACHING

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

THERE ARE ONLY TWO HARD THINGS IN COMPUTER SCIENCE: CACHE INVALIDATION AND NAMING THINGS. - PHIL KARLTON

Slide 17

Slide 17 text

WHY IS IT HARD? IS IT NOT JUST REFRESHING THE BROWSER?

Slide 18

Slide 18 text

CACHING: WHY IS IT HARD? THE TRUTH IS NO LONGER THE TRUTH THE PROBLEM:

Slide 19

Slide 19 text

CACHING: WHY IS IT HARD? THE TRUTH IS NO LONGER THE TRUTH ▸ Responses (answers) you get to queries (for questions) now may or may not be the truth. ▸ Reproducing behavior with truth variability is hard. Reproducing behavior with 15 layers of truth variability, exponentially so.

Slide 20

Slide 20 text

CACHING: WHY IS IT HARD? THE TRUTH IS NO LONGER THE TRUTH ▸ Responses (answers) you get to queries (for questions) now may or may not be the truth. ▸ Reproducing behavior with truth variability is hard. Reproducing behavior with 15 layers of truth variability, exponentially so. HOW DO WE GET AROUND THIS?

Slide 21

Slide 21 text

CACHE INVALIDATION

Slide 22

Slide 22 text

CACHING: INVALIDATION INVALIDATION == REMOVE LAST KNOWN VALUE AND GET NEW VALUE When we “invalidate” the cache, we tell the system that is storing the value, that it needs to forget what it knows now, and get a new value to store.

Slide 23

Slide 23 text

CACHING: INVALIDATION most of the time, cached values have a set expiration date and time. When this set time is reached, the cached value is automagically deleted. CACHE INVALIDATION BY EXPIRATION

Slide 24

Slide 24 text

BUT I WANT IT TO EXPIRE NOW

Slide 25

Slide 25 text

CACHING: INVALIDATION This is what happens when you “hard refresh” your browser. (⌘ (command) + ⇧(shift) + R) YOU CAN FORCE A INVALIDATION BEFORE THE CACHE EXPIRATION DATETIME [ ]

Slide 26

Slide 26 text

CACHING: INVALIDATION This is what happens when you “hard refresh” your browser. (⌘ (command) + ⇧(shift) + R) YOU CAN FORCE A INVALIDATION BEFORE THE CACHE EXPIRATION DATETIME [ ] WHY DOESN’T THIS SOLVE ALL OF MY PROBLEMS THEN?

Slide 27

Slide 27 text

CACHING: INVALIDATION WHY DOESN’T THIS SOLVE ALL OF MY PROBLEMS THEN? because this is only invalidating your browser cache. it’s not invalidating all other layers of caching.

Slide 28

Slide 28 text

A HARD REFRESH ONLY INVALIDATES YOUR BROWSER CACHES. OFTEN IT WILL COVER YOUR NEEDS, BUT IT’S IMPORTANT TO KNOW THERE’S MANY OTHER FACTORS INVOLVED.

Slide 29

Slide 29 text

one last thing

Slide 30

Slide 30 text

3,485,250 23,235 = ?

Slide 31

Slide 31 text

you cached it

Slide 32

Slide 32 text

now you’ve got it. 👍