Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Cache-Control: max-age=31536000
- // Ignore assets that have very high likelihood of cache hit
- const IGNORE_THRESHOLD_IN_PERCENT = 0.925;
- ...
- const cacheHitProbability = CacheHeaders.getCacheHitProbability(cacheLifetimeInSeconds);
- if (cacheHitProbability > IGNORE_THRESHOLD_IN_PERCENT) continue;
- ...
- static getCacheHitProbability(maxAgeInSeconds) {
- // This array contains the hand wavy distribution of the age of a resource in hours at the time of
- // cache hit at 0th, 10th, 20th, 30th, etc percentiles.
- // Example: a max-age of 12 hours already covers ~50% of cases, doubling to 24 hours covers ~10% more.
- ...
- const RESOURCE_AGE_IN_HOURS_DECILES = [0, 0.2, 1, 3, 8, 12, 24, 48, 72, 168, 8760, Infinity];
- assert.ok(RESOURCE_AGE_IN_HOURS_DECILES.length === 12, 'deciles 0-10 and 1 for overflow');
Add Comment
Please, Sign In to add comment