ricardomol
  • Ricardomol Notes
  • Frontend
    • Javascript Toolchain
    • Javascript
      • Quirks
      • Articles
        • Function caching
        • 12 JS Tricks
      • Closures
      • Assorted
      • ES6
      • this
      • OOP
      • Async Programming
      • Functional Programming
      • Typescript
    • React
      • Patterns
        • Render props
      • React Router
    • Webpack
    • CSS
      • Resources
  • Backend
    • Python
      • Shallow copy vs deep copy
      • Classes
      • Resources
      • Python C Extensions
      • Coroutines
      • Exceptions
      • Context managers
      • One-Liners
      • Open function
      • Object introspection
      • Targeting Python 2 + 3
      • For - else
      • Comprehensions
      • Lambdas
      • __slots__ magic
      • Collections
      • Enumerate
      • Mutation
      • Map, Filter and Reduce
      • Decorators
      • Sets
      • Fluent Python summary
      • Quizes / Tips
      • Generators
    • Django
      • Generic Relations
      • FBV's vs CBV's
      • ORM
      • DRF
    • RESTful Architecture
    • Resources
  • Databases
    • Joins
    • Normalization
    • PostgreSQL
  • DevOps
    • Docker
      • 0. Resources
      • 2. Services
      • 3. Swarms
      • 5. Stacks
      • 6. Deploy your app
    • CI
      • CI with Django
    • CD
    • PaaS
    • WSGI servers
    • Django
      • Django Deployment
    • Modern DevOps with Django
  • Git
    • Git
  • Comp Sci
    • Big O Notation
    • Patterns
    • Programming paradigms
  • Assorted
    • TCP vs UDP
    • Tests
    • MongoDB
    • Node
      • Resources
    • Go
    • HTTP vs HTTP2
    • GraphQL
    • Books
    • Vim
    • IPv4 vs IPv6
    • Regex
    • Redis
    • Celery
      • Brokers
    • Caching
  • SECURITY
    • Security
Powered by GitBook
On this page
  • Caching
  • Caching backends
  • Caching resources
  • Caching learning checklist
  1. Assorted

Caching

PreviousBrokersNextSecurity

Last updated 6 years ago

Caching

Can reduce the load on servers by storing the results of common operations and serving the precomputed answers to clients.

For example, instead of retrieving data from database tables that rarely change, you can store the values in-memory.

A cache can be created for multiple layers of the stack.

Caching backends

  • is a common in-memory caching system.

  • is a key-value in-memory data store that can easily be configured for caching with libraries such as and the similarly-named, but separate project .

Caching resources

  • is a wonderful in-depth post that goes into detail on how they handle caching their Python web app for .

  • "" reviews some considerations such as SSL and SPDY support when choosing reverse proxy Nginx or Varnish.

  • has diagrams of how web request caching layers work. The post is relevant reading even though the author is describing his Microsoft code as the impetus for writing the content.

  • While caching is a useful technique in many situations, it's important to also note that there are that many developers fail to take into consideration.

  • covers monitoring, tuning and scaling for the very high scale website.

  • provides more advanced advice on caching dynamic as well as static content via CDNs and other configurations.

Caching learning checklist

  1. Analyze your web application for the slowest parts. It's likely there are complex database queries that can be precomputed and stored in an in-memory data store.

  2. Incorporate a cache invalidation scheme so the precomputed results remain accurate when served up to the user.

Leverage your existing in-memory data store already used for session data to cache the results of those complex database queries. A can often be used to precompute the results on a regular basis and save them in the data store.

memcached
Redis
django-redis-cache
django-redis
Caching at Reddit
billions of pageviews each month
Caching: Varnish or Nginx?
Caching is Hard, Draw me a Picture
downsides to caching
Caching at Reddit
Reddit.com
Mastering HTTP caching
task queue