HTTP Headers: Controlling Cache and History Mechanism

I’ll answer my own question: Static public content Date: <current time> Expires: <current time + one year> Rationale: This is compatible with the HTTP/1.0 proxies and RFC 2616 Section 14: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21 The Last-Modified header is not needed for correct caching (because conforming user agents follow the Expires header) but may be included for the end … Read more

RewriteRule checking file in rewriten file path exists

RewriteRule ^pages/([^/\.]+) cache/pages/$1.html [NC,QSA] # At this point, we would have already re-written pages/4 to cache/pages/4.html RewriteCond %{REQUEST_FILENAME} !-f # If the above RewriteCond succeeded, we don’t have a cache, so rewrite to # the pages.php URI, otherwise we fall off the end and go with the # cache/pages/4.html RewriteRule ^cache/pages/([^/\.]+).html pages.php?p=$1 [NC,QSA,L] Turning off … Read more

How To Disable AFNetworking Cache

Cacheing is handled application-wide by NSURLCache. If you don’t set a shared cache, requests are not cached. Even with a shared NSURLCache, the default implementation on iOS does not support disk cacheing anyway. That said, unless you have a very particular reason to write your own cacheing system, I would strongly recommend against it. NSURLCache … Read more

.Net Core MemoryCache PostEvictionCallback not working properly

To add onto the accept answer and comments, you can force the cache to expire and evict automatically by using a expiring cancellation token. int expirationMinutes = 60; var expirationTime = DateTime.Now.Add(expirationMinutes); var expirationToken = new CancellationChangeToken( new CancellationTokenSource(TimeSpan.FromMinutes(expirationMinutes + .01)).Token); var cacheEntryOptions = new MemoryCacheEntryOptions() // Pin to cache. .SetPriority(CacheItemPriority.NeverRemove) // Set the actual … Read more

When Does Asp.Net Remove Expired Cache Items?

Hurray for Reflector! Expired cache items are actually removed (and callbacks called) when either: 1) Something tries to access the cache item. 2) The ExpiresBucket.FlushExpiredItems method runs and gets to item. This method is hard-coded to execute every 20 seconds (the accepted answer to the StackOverflow question Changing frequency of ASP.NET cache item expiration corroborates … Read more