Guest User

Untitled

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