Azure Cache Preview cache getting reset - caching

I have a default cache that is fairly small and static. It contains just string keys and a string objects.
Since I won't be using anywhere near the allowed amount of memory, I'd like to just preload all of the objects into the cache on startup and have them never expire. I added a log message on start indicating that the cache was loaded.
Right now the project is still in development so the cache isn't being hit often (other than by web spiders/crawlers/scripts). The problem I'm seeing is that every hour to few hours, I'm seeing the log message that my cache was loaded. I'd expect it to load once and then not reload until I force it to.
Is there any way to keep the cache "alive" so that it doesn't have to frequently reload? Is it like an IIS worker process that dies out after some amount of inactivity?
FYI I have the cache configured for Expiry Policy: Never, Time: 0min, Eviction: Disabled. Also the way I check if the cache is still alive is that on load I add a special object to the cache. Then I check to see if that object exists and if it doesn't I assume the cache needs to be reloaded.

For anyone else who stumbles across this I ended up creating a scheduled task that hit the cache every 5 minutes. Since then, I haven't seemed to have any issues with it reloading. Not sure if this is the best answer, but it worked for me.

Related

How to refetch apollo watchQuery after cache invalidation with cache-first / cache-and-network

I have some meta data which rarely updates, but it can update once in a while. Within my application the user access this information very frequently, which puts quite some load on my servers.
I'd like to refetch it only eg once a day to check if something changed.
My expected behavior is watchQuery should immediately return, even though cache is expired. Only if cache is expired it refetches to update cache
Is this anyhow possible?
My first idea was to tell cache-and-network or cache-first to only use network if the last network check is eg older than an day or cache got invalidated, but could not find anything on this in the document.
Thx I really appreciate your expertise.

How to clear a browser cached service worker when the old site is no longer accessible?

I have built a new site for a customer and taken over managing their domain and using a new hosting. The previous site and hosting have been completely taken down.
I am running into a major issue that I am not sure how to fix. The previous developer used a service worker to cache and load the previous site. The problem is that users that had previous visited the site keep seeing the old one since it is all loading from a cache. This old site no longer even exists so I have no way of adding any javascript to remove the service worker from their browser unless they hit the new site.
Has anyone ever had this issue and know of a way to resolve it? Note, asking the users to delete the service worker from their browser won't work.
You can use cache busting to achieve the outcome. As per Keycdn
Cache busting solves the browser caching issue by using a unique file
version identifier to tell the browser that a new version of the file
is available. Therefore the browser doesn’t retrieve the old file from
cache but rather makes a request to the origin server for the new
file.
In case you want to update the service worker itself, you should know, for a service worker an update is triggered if any of the following happens:
A navigation to an in-scope page.
A functional events such as push and sync, unless there's been an update
check within the previous 24 hours.
Calling .register() only if the service worker URL has changed. However, you should avoid changing the worker URL.
Updating the service worker
Maybe using the clear-site-data header would be the most thorough solution.

In-memory cache in ASP.NET Core emptied immediately

I am trying to implement temporary ip blocking for my ASP.NET Core application and everything I have read on how to do this uses caching.
I have followed this article to learn about in-memory caching in asp.net core:
https://learn.microsoft.com/en-us/aspnet/core/performance/caching/memory
The code is running okay, but the cache is emptied immediately after an action is completed.
If a put a break-point on this line:
_cache.Set(CacheKeys.Entry, cacheEntry, cacheEntryOptions);
I can see that _cache indeed has the proper value. However, that value is gone the next time I reload the page. Regardless of how long I set the expiration time to or even if I set
CacheItemPriority.NeverRemove
in the cacheEntryOptions.
I have also tried registering a callback for the eviction of the item from the cache to see if it was being evicted immediately due to memory pressure. However, the callback is never called.
Is there some server options I need to enable to allow caching?
I met the similar issue today. And found that the cache only save the reference of the value. So if you save a List in to the cache and Clear the List later. The cached List will also be cleared, but key is still there.
Source code is here:https://source.dot.net/#Microsoft.Extensions.Caching.Abstractions/MemoryCacheExtensions.cs,bc5684b7eae179d4

Can't Re-enable Magento Cache in admin

I am having performance problems with my website and after profiling noticed that it looked like the cache was not being loaded. So I went to admin and looked at the Cache Management page and all caches were disabled. I re-enabled them and sometimes one will show as enabled, sometimes none will.
When I am able to get Configuration cache to show as enabled, I can view the profiler on the front end and see the line:
mage::app::init::config::load_cache
This line was not showing in the profiler before I enabled the cache. However, after a short period of time (30 seconds or so), any caches that were enabled show as disabled again and the front end profiler no longer has this line (the cache isn't being used).
So far, I can not get the cache to stay on. I have apache ownership on the var/cache and 777 permissions. The files are created there initially, but I am also use apc cache.
Configuration is:
<cache>
<backend>apc</backend>
<prefix>SH_</prefix> </cache>
Does anyone have any ideas?
Try changing the <prefix>SH_</prefix> setting to something that is guaranteed to be unique, e.g. your database name.
Background
Given the information you provided, I suspect another Magento instance is running on the same machine with the same cache prefix.
Whenever you change the settings, Magento writes them to the database, and then also saves the cache (see Mage_Core_Model_Cache::_initOptions()). Because the Magento instances share the same fast backend cache pool (because of the identical prefix), the settings are also used by the other host. Once the cache is cleared by the other host, their (disabled) setting is written to the cache. Now your Instance also sees the caches as disabled.
I'm unable to provide evidence without the option to test, but, well, this is my best guess.

Appfabric cache (Velocity): Expiration in non-expirable cache and unreadable trace log?

we are using Appfabric cache in our project, and we ran into 2 major problems.
First - we are using named caches (no explicitly created regions). One of them, created as Expirable=false, Eviction=none, TTL=525600 is used for objects that should be always available (populated at application start, via the Put method). But from time to time (i couldnt identify exact timespan, nor connection to certain actions in application) all object in this cache suddenly expires - i can see this from performance counters - object count for this cache goes to 0, total expired objects counter increases of the amount of objects in this cache at the same time. Am i missing some other settings ? I tried both inserting them via Put() without timespan, and Put with timespan "a year". Still expires after several minutes...
The second problem - when I tried to solve first problem, i decided to use ETW trace logging feature to see in log, what is happening. I have created tracelog via logman and started it, waited for cache to expire, stopped the log, and have used tracerpt to create dumpfile from etl. Everything ok so far. But this dumpfile is useless, because there are no readable data, only 4400690073007400720....... After some quick research, i figured out, that I need to supply an PDB or TMF file to tracerpt, so it can "decode" binaryeventdata to readable eventdata. Is it possible to get some of these for appfabric cache ? Or there is some other way to use ETW with appfabric to get some usefull readable log ?
I found out what the problem is when your cache is expiring nearly instantly.
If your memory is low the cache gets cleared.
Check in the eventvwr -> Applicatin and Service -> Microsoft -> Windows - Application Server System Services and select Operational.
Look for warnings like:
Service available memory low - Cache private bytes percent {2} Cache working set percent {1} Cache data size percent {0} Available memory percent {21} CLR Generation2 count {2013} Released memory percent {0}.
There is an explanation in here to convert log file to cvs: http://msdn.microsoft.com/en-us/library/ff921010.aspx
But I can not even use tracelog tool.

Resources