Integrate Caching and Content Delivery Flashcards
Basic request/response lifecycle
User makes request.
If the CDN (.azureedge.net) doesn’t have the file, it goes to the origin server and requests the file.
The file is cached and remains cached until the Time To Live specified in the HTTP header. If the origin server doesn’t specify, the default is 7 days.
The file gets cached in the CDN and can be used for other user requests
What are the 2 ways you control how your files are cached in the CDN?
- Caching rules (global or custom)
2. Query string caching
Azure Redis Cache is…
In-memory cache.
CDN is storage account in Point of Presence (POP) servers.
How much time does it usually take for propagation to complete for Azure CDN Standard from Akamai profiles?
1 minute. For Azure CDN Standard from Verizon profiles, propagation usually completes in 10 minutes.
What are the two types of caching rules offered by Azure CDN?
Global and custom.
Custom overrides global.
What is the difference between global and custom caching rules in Azure CDN?
Global: Only one per CDN endpoint. Affects all requests to the endpoint.
Custom: One or many rules allowed. Allow you to specify caching behavior for specific file or path in your app. Override global caching rule
What are the 4 pricing tiers in Azure CDN?
Azure CDN Standard from Microsoft
Azure CDN Standard from Akamai
Azure CDN Standard from Verizon
Azure CDN Premium from Verizon.
Describe the 4 options for global caching rules.
Can override HTTP headers sent by clients.
4 options:
1. Bypass Cache: no items are cached at all even if caching headers set
2. Override: override headers setting default cache duration for all items
3. Set if missing: applies a custom TTL if the cache control header has not been set by the requesting client
4. Not set: honors any cache control headers that have been set, but won’t change the TTL value
Explain query string caching in CDNs.
Define how requests that contain query strings are dealt with.
- Ignore them (default) : CDN passes the query string from the requesting client through to the origin server on the first request and caches the asset that’s returned. Subsequent requests ignore the query string until the cached asset expires.
- Bypass query string: Any requests containing query strings are not cached at all by the CDN, and asset is retrieved directly from origin server and passed directly to the client
- Cache every unique URL: every unique URL is treated as an asset with its own cache and its own time to live. Don’t use this mode if your URLs contain query string values that change with every request. This would result in poor performance.
What are some common uses for Redis cache?
User session storage for distributed apps
Database caching (specific queries to the database)
Content caching
Distributed transactions
Message broker
What are some considerations you should make when determining tier of Azure Redis cache?
Overall cache size (amount of data stored in cache)
General network performance (low, moderate, high)
# of client connections
What are the 3 ways an item can be removed from Redis cache?
- TTL (scheduled deletion - “volatile item”)
- Manual removal using a client library
- Eviction (happens under memory pressure. Can’t control this). Can control the policy of how this happens.
What is the default eviction policy in Azure Redis cache?
volatile-lru (least recently used) - evaluates (and deletes) the lease recently used volatile items
Besides volatile-lru, what are the other eviction policy options?
Allkeys-lru - evaluates (and deletes) all items for lru (not just items that have a TTL)
No eviction
Volatile-random: selects at random volatile item to be removed
Allkeys-random: selects items at random from both volatile and non-volatile
Volatile-ttl: remove items with the shortest ttl remaining
When deciding what data to cache in Redis, what are some considerations?
Repeatedly accessed data (especially if it remains unchanged - this allows you to cache static and/or dynamic data if dynamic remains unchanged)
Data source performance: querying data from sql is significantly slower than retrieving from Redis cache
Data contention: if you have multiple processes within App all competing for access to the same data, then you should definitely consider that data for caching
Location of the data: if your db is on-prem or in another location, data should be considered for caching