Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
Force IE8 *not* to use Compatibility View |
Just updated my site to newer, much more standards compliant design. My previous design was so rubbish that I had to use the IE=EmulateIE tag to force IE7 emulation.
Unfortunately, I believe that browsers may be caching this setting from previous visits, causing my new site (which looks great without the button press... |
51
In the absence of an X-UA-Compatible http-equiv header, the compatibility mode is determined by the !DOCTYPE (or the absence of a !DOCTYPE, as the case may be). For a chart of which !DOCTYPE gives you which mode (in various browsers) see here:
http://hsivonen.iki.fi/doc... |
How can I cache objects in ASP.NET MVC? |
I'd like to cache objects in ASP.NET MVC. I have a BaseController that I want all Controllers to inherit from. In the BaseController there is a User property that will simply grab the User data from the database so that I can use it within the controller, or pass it to the views.
I'd like to cache this information. I... |
You can still use the cache (shared among all responses) and session (unique per user) for storage.
I like the following "try get from cache/create and store" pattern (c#-like pseudocode):
public static class CacheExtensions
{
public static T GetOrStore<T>(this Cache cache, string key, Func<T> generator)
{
... |
Enabling Service Broker in SQL Server 2008 |
I am integrating SqlCacheDependency to use in my LinqToSQL datacontext.
I am using an extension class for Linq querys found here - http://code.msdn.microsoft.com/linqtosqlcache
I have wired up the code and when I open the page I get this exception -
"The SQL Server Service Broker for the current database is not enabl... |
ok here is how to do this if yours is disabled or you need to restore a backup, which seems to disable it.
just run this script, it will kill all the process's that a database is using (why you carnt in 2008 manually kill process's unlike 2005 is beyond me) and then set the broker
USE master
go
DECLARE @dbname sysnam... |
how to clear or replace a cached image |
I know there are many ways to prevent image caching (such as via META tags), as well as a few nice tricks to ensure that the current version of an image is shown with every page load (such as image.jpg?x=timestamp), but is there any way to actually clear or replace an image in the browsers cache so that neither of the... |
67
If you're writing the page dynamically, you can add the last-modified timestamp to the URL:
<img src="image.jpg?lastmod=12345678" ...
Share
Improve this answer
Follow
answered Nov 26, 2008 at ... |
What's the difference between conflict miss and capacity miss |
Capacity miss occurs because blocks are being discarded from cache because cache cannot contain all blocks needed for program execution (program working set is much larger than cache capacity).
Conflict miss occurs in the case of set associative or direct mapped block placement strategies, conflict misses occur when s... |
The important distinction here is between cache misses caused by the size of your data set, and cache misses caused by the way your cache and data alignment are organized.
Lets assume you have a 32k direct mapped cache, and consider the following 2 cases:
You repeatedly iterate over a 128k array. There's no way the d... |
alternative to memcached that can persist to disk |
I am currently using memcached with my java app, and overall it's working great.
The features of memcached that are most important to me are:
it's fast, since reads and writes are in-memory and don't touch the disk
it's just a key/value store (since that's all my app needs)
it's distributed
it uses memory efficientl... |
Maybe your problem is like mine: I have only a few machines for memcached, but with lots of memory. Even if one of them fails or needs to be rebooted, it seriously affects the performance of the system. According to the original memcached philosophy I should add a lot more machines with less memory for each, but that'... |
Cached Property: Easier way? |
I have a object with properties that are expensive to compute, so they are only calculated on first access and then cached.
private List<Note> notes;
public List<Note> Notes
{
get
{
if (this.notes == null)
{
this.notes = CalcNotes();
}
... |
As far as syntax goes, you can use the null-coalescing operator if you want to be fancy, but it's not necessarily as readable.
get
{
return notes ?? (notes = CalcNotes());
}
Edit: Updated courtesy of Matthew. Also, I think the other answers are more helpful to the question asker!
|
No cache in Node.js server |
I have read that to avoid caching in Node.js, it is necessary to use:
res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
But I don't know how to use it because I get errors when I put that line in my code.
My function (where I think I have to program t... |
You've already written your headers. I don't think you can add more after you've done that, so just put your headers in your first object.
res.writeHead(200, {
'Content-Type': mimeType,
'Content-Length': contents.length,
'Accept-Ranges': 'bytes',
'Cache-Control': 'no-cache'
});
|
Chrome - ERR_CACHE_MISS |
Does anybody know what the following Chrome error is?
Failed to load resource: net::ERR_CACHE_MISS
I have had a look online, but have not found a good answer yet. Somebody said it might be related to the latest Chrome update?
What is it and how can I resolve the issue?
Cheers
|
Yes, this is a current issue in Chrome. There is an issue report here.
The fix will appear in 40.x.y.z versions.
Until then? I don't think you can resolve the issue yourself. But you can ignore it. The shown error is only related to the dev tools and does not influence the behavior of your website. If you have any oth... |
How to retrieve a list of Memory Cache keys in asp.net core? |
To be succinct. Is possible list all register keys from Memory Cache in the .Net Core Web Application?
I didn't find anything in IMemoryCache interface.
|
There is no such thing in .Net Core yet.
Here is my workaround:
var field = typeof(MemoryCache).GetProperty("EntriesCollection", BindingFlags.NonPublic | BindingFlags.Instance);
var collection = field.GetValue(_memoryCache) as ICollection;
var items = new List<string>();
if (collection != null)
foreach (var item... |
Un-persisting all dataframes in (py)spark |
I am a spark application with several points where I would like to persist the current state. This is usually after a large step, or caching a state that I would like to use multiple times. It appears that when I call cache on my dataframe a second time, a new copy is cached to memory. In my application, this leads to... |
Spark 2.x
You can use Catalog.clearCache:
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate
...
spark.catalog.clearCache()
Spark 1.x
You can use SQLContext.clearCache method which
Removes all cached tables from the in-memory cache.
from pyspark.sql import SQLContext
from pyspark import... |
How to specify HTTP expiration header? (ASP.NET MVC+IIS) |
I am already using output caching in my ASP.NET MVC application.
Page speed tells me to specify HTTP cache expiration for css and images in the response header.
I know that the Response object contains some properties that control cache expiration. I know that these properties can be used to control HTTP caching for r... |
Found it:
I need to specify client cache for static content (in web.config).
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public"
cacheControlMaxAge="12:00:00" cacheControlMode="UseMaxAge" />
</staticContent>
</system.webServer>
</configuration>
from ht... |
Linux C++: how to profile time wasted due to cache misses? |
I know that I can use gprof to benchmark my code.
However, I have this problem -- I have a smart pointer that has an extra level of indirection (think of it as a proxy object).
As a result, I have this extra layer that effects pretty much all functions, and screws with caching.
Is there a way to measure the time my CP... |
21
You could try cachegrind and it's front-end kcachegrind.
Share
Improve this answer
Follow
answered Mar 21, 2010 at 11:53
TaaviTaavi
32122 silver badges33 bronze badges
0
Ad... |
Python LRU Cache Decorator Per Instance |
Using the LRU Cache decorator found here:
http://code.activestate.com/recipes/578078-py26-and-py30-backport-of-python-33s-lru-cache/
from lru_cache import lru_cache
class Test:
@lru_cache(maxsize=16)
def cached_method(self, x):
return x + 5
I can create a decorated class method with this but it ends ... |
Assuming you don't want to modify the code (e.g., because you want to be able to just port to 3.3 and use the stdlib functools.lru_cache, or use functools32 out of PyPI instead of copying and pasting a recipe into your code), there's one obvious solution: Create a new decorated instance method with each instance.
clas... |
Difference between django-redis-cache and django-redis for redis caching with Django? |
I noticed that there are two different projects for using redis for django cache
https://github.com/sebleier/django-redis-cache/
https://github.com/niwibe/django-redis
Is one better known than the other, more of a standard package? I can't decide which to use.
|
I am currently using django-redis as cache backend for Redis. I haven't used django-redis-cache so far, but what made me take the decision to use django-redis are the following:
Modular client system (pluggable clients).
Some of the pluggable clients come out of the box (shard client, herd client, etc.)
Master-Slave ... |
How to find and fix a Rails and Couchbase memory leak |
I have the following test code:
def loop_bucket_gets
bucket = Couchbase::Bucket.new({:node_list => ['xxx.xxx.xxx.xxx:8091', 'yyy.yyy.yyy.yyy:8091'],
:bucket => 'Foo',
:pool => 'default',
:expires_in => 1.day... |
0
There is no terminating condition in your loop so it's going to run forever and cause the memory issue you mentioned. You should add a relevant break condition in your loop and test if it resolves the issue.
def loop_bucket_gets
bucket = Couchbase::Bucket.new({:node_l... |
Configure multiple sites with Varnish |
We have a server which needs to serve multiple domains though varnish e.g. example1.com, example2.com and example3.com
Our current .vcl file looks like this:
sub vcl_recv {
set req.http.Host = "example1.com";
lookup;
}
How do I set the correct req.http.Host for the correct incoming request?
|
You can support multiple frontend domains this way:
backend example1 {
.host = "backend.example1.com";
.port = "8080";
}
backend example2 {
.host = "backend.example2.com";
.port = "8080";
}
sub vcl_recv {
if (req.http.host == "example1.com") {
#You will need the following line on... |
Cache Control for Dynamic Data Express.JS |
How it is possible to set up a cache-control policy in express.js on JSON response?
My JSON response doesn't change at all, so I want to cache it aggressively.
I found how to do caching on static files but can't find how to make it on dynamic data.
|
The inelegant way is to simply add a call to res.set() prior to any JSON output. There, you can specify to set the cache control header and it will cache accordingly.
res.set('Cache-Control', 'public, max-age=31557600'); // one year
Another approach is to simply set a res property to your JSON response in a route the... |
When does browser automatically clear cache of external JavaScript file? |
I have a JavaScript resource that has the possibility of being edited at any time. Once it is edited I would want it to be propagated to the user's browser relatively quickly (like maybe 15 minutes or so), however, the frequency of this resource being editing is few and far between (maybe 2 a month).
I'd rather the re... |
You may pass a version string as a get parameter to the URL of your script tag. The parameter won't be evaluated by the static JavaScript file but force the browser to get the new version.
If you do not want to assign the version string every time you edited the source you may compute it based on the file system time... |
Memory Cache or Concurrent Dictionary? |
I am looking to implement caching at a request level for a WCF Service. Each request to this service performs a large number of database calls. Think multiple data collectors. We need to allow one data collector to access the information already retrieved by a preceding data collector.
I was looking to use the new .Ne... |
If you don't need some kind of expiration logic, I would suggest using concurrent collections. You can easily implement a single entry caching mechanism combining ConcurrentDictionary and Lazy classes. Here is another link about Lazy and ConcurrentDictionary combination.
If you need your items to expire, then you bett... |
Is there any nosql flat file database just as sqlite? [closed] |
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to ... |
Maybe shelve? It's basically a key-value store where you can store python objects. http://docs.python.org/library/shelve.html
Or maybe you could just use the filesystem?
|
Symfony: Clear doctrine cache |
I need to clear my doctrine's cache in Symfony.
There must be some way in command line for clear the cache.
Or where should I find and delete the files belonging to cache?
|
For Symfony 3+:
php bin/console
will list all commands, the following are relevant for cache:
php bin/console doctrine:cache:clear-metadata
php bin/console doctrine:cache:clear-query
php bin/console doctrine:cache:clear-result
Before Symfony 3:
app/console
will list how you can do it
app/console doctrine:c... |
What happens to SDWebImage Cached Images in my app when the image file on the server changes? |
I am using the SDWebImage library to cache web images in my app:
https://github.com/rs/SDWebImage/blob/master/README.md
Current Usage:
[imageView setImageWithURL:[NSURL URLWithString:profilePictureUrl] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
My question is what happens once the image has been cache... |
I had a look at the source code. It processes the setImageWithURL method like this:
Ask the memory cache if the image is there, if yes return the image and don't go any further
Ask the disk cache if the image is there, if yes return the image and don't go any further
Try to download the image, return image on success... |
is Rails.cache purged between tests? |
We cache id/path mapping using Rails.cache in a Rails 3.2 app. On some machines it works OK, but on the others values are wrong. The cause is hard to track so I have some questions about the Rails.cache itself. Is it purged between tests? Is it possible that values cached in development mode is used in test mode? If i... |
Add:
before(:all) do
Rails.cache.clear
end
to have the cache cleared before each spec file is run.
Add:
before(:each) do
Rails.cache.clear
end
to have the cache cleared before each spec.
You can put this inside spec/spec_helper.rb within the RSpec.configure block to have it applied globally (recommended over sca... |
Repository Pattern - Caching |
I'm not sure where I should implement the caching in my repository pattern.
Should I implement it in the service-logic or in the repository?
GUI -> BusinessLogic (Services) -> DataAccess (Repositories)
|
I would handle it in the repository/data access layer. The reasoning is because it isn't up to the business layer on where to get the data from, that is the job of the repository. The repository will then decide where to get the data from, the cache (if it's not too old) or from the live data source based on the cir... |
How to cache Google map tiles for offline usage? |
Like Nokia's OVI maps can be used offline, there must be some way of caching Google map tiles too. Any hints?
|
Unfortunately, I found this link which appears to indicate that we cannot cache these locally, therefore making this question moot.
http://support.google.com/enterprise/doc/gme/terms/maps_purchase_agreement.html
4.4 Cache Restrictions. Customer may not pre-fetch, retrieve, cache, index, or store any Content, or porti... |
X-Cache Header Explanation |
I was going through the firefox local cache folder and found a lot of files containing the X-cache header. Can someone explain the purpose of this header ?
thanks
|
32
CDN (Content Delivery Network) adds X-cache header to HTTP Response. X-cache:HIT means that your request was served by CDN, not origin servers. CDN is a special network designed to cache content, so that usr request served faster + to unload origin servers.
Share... |
How to use JPA2's @Cacheable instead of Hibernate's @Cache |
Typically , I use Hibernate's @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) to cache an @Entity class , and it works well.
In JPA2 , there's another @Cacheable annotation that seems to be the same functionality with Hibernate's @Cache. To make my entity class independent of hibernate's package , I wan... |
According to the JPA 2.0 specification, if you want to selectively cache entities using the @Cacheable annotation, you're supposed to specify a <shared-cache-mode> in the persistence.xml (or the equivalent javax.persistence.sharedCache.mode when creating the EntityManagerFactory).
Below, a sample persistence.xml with... |
Is something wrong with the dynamic keyword in C# 4.0? |
There is some strange behavior with the C# 4.0 dynamic usage:
using System;
class Program {
public void Baz() { Console.WriteLine("Baz1"); }
static void CallBaz(dynamic x) { x.Baz(); }
static void Main(string[] args) {
dynamic a = new Program();
dynamic b = new { Baz = new Action(() => Console.WriteLin... |
I can confirm that this is indeed a bug. The quick description of what's going wrong here is as follows: In CallBaz, there is a single callsite that is invoked three times. That callsite is an InvokeMember, because that's the best guess the compiler can make given the C# syntax, despite that it could, in actuality, re... |
Is there an API to force Facebook to scrape a page again? |
I'm aware you can force update a page's cache by entering the URL on Facebook's debugger tool while been logged in as admin for that app/page:
https://developers.facebook.com/tools/debug
But what I need is a way to automatically call an API endpoint or something from our internal app whenever somebody from our Sales d... |
Page metadata isn't the sort of thing that should change very often, but you can manually clear the cache by going to Facebook's Debug Tool and entering the URL you want to scrape
There's also an API for doing this, which works for any OG object:
curl -X POST \
-F "id={object-url OR object-id}" \
-F "scrape=... |
Memoize a curried function |
const f = (arg1) => (arg2) => { /* returns something */ }
Is it possible to memoize f with regard to the 2 arguments, namely:
f(1)(2);
f(1)(3); // Cache not hit
f(4)(2); // Cache not hit
f(1)(2); // Cache hit
|
You could take a Map as cache and take nested maps for all following arguments.
This cache works for arbitrary count of arguments and reuses the values from the former calls.
It works by taking a curried function and an optional Map. If the map is not supplied, a new map is created which serves as base cache for all ... |
Caching in Android webview |
Which one is faster way to load mobile web pages and non mobile web pages in Android webview; loading cache or not loading that at all?
And what is recommend style to load that?
Right now when I don't load cache at all non mobile sites are much more slower to load than when I load them in native browser.
|
Don't use these:
viewer.getSettings().setAppCacheMaxSize(1024*1024*8);
viewer.getSettings().setAppCachePath("/data/data/com.your.package.appname/cache");
viewer.getSettings().setAppCacheEnabled(true);
These have nothing to do with the default webview internal cache. Appcache is an entirely different featu... |
Add Expires or Cache Control Header to static content in IIS |
After running the YSlow plugin on a site, I saw that one of the recommendations was to add far future expires headers to the scripts, stylesheets, and images.
I would like to do this, does anyone have experience with this? I am using IIS 7 and I read an article from Microsoft but am not interested in disabling cach... |
8
Can this be done in IIS 6?
To configure content expiration
In the Internet Information Services (IIS) Manager administrative tool, right-click Your Web Site, and then click Properties.
In the Properties dialog box, on the HTTP Headers tab specify expiration time, and t... |
Why does cache use Most Recently Used (MRU) algorithm as evict policy? |
I know the algorithms of MRU and its reversed one Least Recently Used (LRU).
I think LRU is reasonable, as LRU element means it will be used at least possible in future. However, MRU element means the element is very possible to be used in future, why evict it? What is the reasonable scenario?
|
Imagine you were looking up the details of buses as they arrived at a bus stop, based on their bus number (or whatever identifier you use).
It's somewhat reasonable to think that if you've just seen a number 36 bus, you're less likely to see another one imminently than to see one of the other buses that stops there.
J... |
Firebase hosting - force browser to reset cache on new deploys? |
I have a site built with create-react-app and hosted on Firebase Hosting. What can I do to specify the browser cache needs to be updated after new deploys, and ideally only for pages, assets, and stylesheets that have been changed since the last deploy?
Is there a way to access the deploy id and include that (or any o... |
I figured it out. Had to update the firebase.json file according to this Github comment:
{
"hosting": {
"headers": [
{ "source":"/service-worker.js", "headers": [{"key": "Cache-Control", "value": "no-cache"}] }
]
}
}
|
how to force clearing cache in chrome when release new Vue app version |
I created an app with vue-cli and then I build the dist folder for production.
The app is deployed on IIS with flask backend and works fine.
The problem occurs when I have to make some changes and I have to redo the deployment. After this, users call me because app doesn't work but if I clear the chrome cache, the app... |
48
I had the same problem and changing (incrementing) the version number in package.json before running the build command fixed it.
For example by default the version number is set to "0.1.0"
package.json file:
{
"name": "project-name",
"version": "0.1.1",
"private": ... |
Caching Data Objects when using Repository/Service Pattern and MVC |
I have an MVC-based site, which is using a Repository/Service pattern for data access.
The Services are written to be using in a majority of applications (console, winform, and web). Currently, the controllers communicate directly to the services. This has limited the ability to apply proper caching.
I see my optio... |
The easiest way would be to handle caching in your repository provider. That way you don't have to change out any code in the rest of your app; it will be oblivious to the fact that the data was served out of a cache rather than the repository.
So, I'd create an interface that the controllers use to communicate with ... |
What are the compelling reasons to use a MemoryCache over a plain old Dictionary<string,object> |
I have just come across the MemoryCache which is new in .NET 4.
I get that it can be useful if you want to:
Limit the total memory usage of the cache
Have an object expiry time (time to live) for objects you put in the cache
Are there any other compelling reasons to use a MemoryCache over a standard Dictionary<stri... |
I think you nailed the two compelling reasons :-)
The MemoryCache has an eviction strategy, so that it can throw out entries that are no longer needed or for that you do not have enough memory anymore.
A Dictionary will not "lose contents".
Update: MemoryCache is thread-safe and has methods such as AddOrGetExisting. W... |
Why does Entity Framework 6.x not cache results? |
Perhaps I am misunderstanding the caching that DbContext and DbSet does but I was under the impression that there was some caching that would go on. I'm seeing behavior that I wouldn't expect when I run the following code:
var ctx = CreateAContext();
var sampleEntityId = ctx.SampleEntities.Select(i => i.Id)
... |
What @emcas88 is trying to say is that EF will only check the cache when you use the .Find method on DbSet.
Using .Single, .First, .Where, etc will not cache the results unless you are using second-level caching.
|
Force browser to reload index.htm |
how can I force a browser to always load the newest version of index.htm when the page is loaded by entering the URL www.mydomain.com/index.htm or just www.mydomain.com in the browser's address field and pressing enter.
I'm trying this in Chrome and the newest version of index.htm is apparently only loaded, when I ref... |
OK, apparently no-cache was not enough.
The following does the trick:
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 ... |
How do you set the expiry date or a maximum age in the HTTP headers for static resources in IIS |
I am using IIS 6 and IIS 7 as a web server.
After running Google page speed online , it remarks that I should be: Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
And it lists a l... |
Leverage browser caching:
Setting an expiry date or a maximum
age in the HTTP headers for static
resources instructs the browser to
load previously downloaded resources
from local disk rather than over the
network.
http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching
To set an e... |
How to disable cache in InternetExplorer 8 |
How can I disable cache in IE8 ?
We are doing Javascript development and testing it in IE8, but we have to clear the cache every time we make changes to the Javascript files.
|
Go to Internet Options. On the General tab, under Browsing History click Settings. Select the "Every time I visit the webpage" radio button.
This doesn't "disable" the cache per se, but it should fix your underlying problem - the JS files should be reloaded every time.
|
Installing memcached for a django project |
From the django docs:
After installing Memcached itself, you'll need to install a memcached binding. There are several python memcached bindings available; the two most common are python-memcached and pylibmc.
The pylibmc docs have their own requirements:
-libmemcached 0.32 or later (last test with 0.51)
-zlib (requ... |
Just do pip install python-memcached and you should be good.
As for installing memcached itself, it depends on the platform you are on.
Windows - http://pureform.wordpress.com/2008/01/10/installing-memcache-on-windows-for-php/
OS X - brew install memcached
Debian/Ubuntu - sudo apt-get install memcached
On OS X/Linux... |
How do I clear a System.Runtime.Caching.MemoryCache |
I use a System.Runtime.Caching.MemoryCache to hold items which never expire. However, at times I need the ability to clear the entire cache. How do I do that?
I asked a similar question here concerning whether I could enumerate the cache, but that is a bad idea as it needs to be synchronised during enumeration.
I've t... |
You should not call dispose on the Default member of the MemoryCache if you want to be able to use it anymore:
The state of the cache is set to indicate that the cache is disposed.
Any attempt to call public caching methods that change the state of
the cache, such as methods that add, remove, or retrieve cache
... |
ConfigurationManager.AppSettings Caching |
We know that IIS caches ConfigurationManager.AppSettings so it reads the disk only once until the web.config is changed. This is done for performance purposes.
Someone at:
http://forums.asp.net/p/1080926/1598469.aspx#1598469
stated that .NET Framework doesn't do the same for app.config, but it reads from the disk for ... |
A quick test seems to show that these settings are only loaded at application startup.
//edit the config file now.
Console.ReadLine();
Console.WriteLine(ConfigurationManager.AppSettings["ApplicationName"].ToString());
Console.WriteLine("Press enter to redisplay");
//edit the config file again now.
Console.ReadLine()... |
Is System.Web.Caching or System.Runtime.Caching preferable for a .NET 4 web application |
I am adding caching to an ASP.NET web application. This is .NET 4, so I can use the classes in the System.Runtime.Caching namespace (which, as I understand it, was added to provide similar functionality to that found in System.Web.Caching, but for non-Web-apps.)
But since this is a web app, am I better off using Syst... |
Microsoft recommends using System.Runtime.Caching for all caching purposes. See this: http://msdn.microsoft.com/en-us/library/dd997357.aspx
Although, I have come across a couple threads where people are having issues with the MemoryCache.Default instance. After a while, it stops working properly. Any item you add usin... |
AngularJs force browser to clear cache [duplicate] |
This question already has answers here:
Clear browser cache in Angular
(4 answers)
Closed 3 years ago.
My angular application is constantly changing these days because our team run... |
You can use a very simple solution that consist in append a hash to your scripts files. Each time your App is deployed you serve your files with a different hash automatically via a gulp/grunt task. As an example you can use gulp-rev. I use this technique in all my projects and works just fine, this automatized in you... |
How to disable caching with HttpClient get in Angular 6 |
I'm writing an Angular SPA app, that uses HttpClient to get values from my backend.
What is the easy way to tell it not to cache? The first time I ask it gets the value, then it refuses to make subsequent queries.
Thanks,
Gerry
|
Using meta HTML tags, Disable browser caching:-
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
or,
Add headers in http request as:-
headers = new Headers({
'Cache-Control': ... |
How to automatically refresh Cache using Google Guava? |
I am using Google Guava library for caching.
For automatic cache refresh we can do as follows:
cache = CacheBuilder.newBuilder()
.refreshAfterWrite(15, TimeUnit.MINUTES)
.maximumSize(100)
.build(....);
However, automatic refreshes are performe... |
Guava provides no way to refresh the cache in bulk, but you can schedule a periodic refresh yourself:
LoadingCache<K, V> cache = CacheBuilder.newBuilder()
.refreshAfterWrite(15, TimeUnit.MINUTES)
.maximumSize(100)
.build(new MyCacheLoader());
for (K key : cache.asMap().keySet()) {
cache.re... |
Architecture for Redis cache & Mongo for persistence |
The Setup:
Imagine a 'twitter like' service where a user submits a post, which is then read by many (hundreds, thousands, or more) users.
My question is regarding the best way to architect the cache & database to optimize for quick access & many reads, but still keep the historical data so that users may (if they wan... |
It is actually sensible to associate Redis and MongoDB: they are good team players. You will find more information here:
MongoDB with redis
One critical point is the resiliency level you need. Both Redis and MongoDB can be configured to achieve an acceptable level of resiliency, and these considerations should be disc... |
Is there a way to clear the cache used by UIImage class? |
It is well known that UIImage caches its image data when the image is loaded using the imageNamed: method.
From apple documentation:
https://developer.apple.com/documentation/uikit/uiimage/1624146-imagenamed
imageNamed:
Discussion: This method looks in the
system caches for an image object with
the specified name... |
Answer taken from Kevin Low comment
If you can use private APIs (as in an AdHoc only app, for example) use this UIImage method to remove all images from cache
[UIImage _flushSharedImageCache];
|
Slow start for AVAudioPlayer the first time a sound is played |
I'm trying to eliminate startup lag when playing a (very short -- less than 2 seconds) audio file via AVAudioPlayer on the iPhone.
First, the code:
NSString *audioFile = [NSString stringWithFormat:@"%@/%@.caf", [[NSBundle mainBundle] resourcePath], @"audiofile"];
NSData *audioData = [NSData dataWithContentsOfMappedFil... |
The delay seems to be related to instantiating AVAudioPlayer for the first time. If I load any audio, run [audioPlayer prepareToPlay] and then immediately release it, the load times for all of my other audio is very close to imperceptible. So now I'm doing that in applicationDidFinishLaunching and everything else runs... |
iOS - Caching and loading images asynchronously |
I want an image loading and caching library for iOS that
loads images asynchronously,
caches images, with a configurable cache size and LRU behaviour,
checks to see if images have been updated, using HTTP HEAD,
doesn't cache anything in the event of an error code or an invalid image.
I've looked at HJCache, but it o... |
I know that this thread has been answered, but I have tried a library that has worked great. I was using ASIHttpRequest before and the difference is big.
https://github.com/rs/SDWebImage
Also, if someone needs to Resize or Crop the remote images, and have the same features that SDWebImage provide, I have integrated SD... |
Why is the size of L1 cache smaller than that of the L2 cache in most of the processors? |
Why is the size of L1 cache smaller than that of the L2 cache in most of the processors ?
|
There are different reasons for that.
L2 exists in the system to speedup the case where there is a L1 cache miss. If the size of L1 was the same or bigger than the size of L2, then L2 could not accomodate for more cache lines than L1, and would not be able to deal with L1 cache misses. From the design/cost perspectiv... |
How to cache in Symfony 2? |
I need to cache some application specific data using Symfony 2's caching system so that I can run cache:clear to clear it. All the cache relies under app/cache but how do I actually go about caching data?
http://symfony.com/doc/current/cookbook/index.html
The only topic I see is about HTML caching with Varnish.
|
If you are using Doctrine already just use those cache classes.
Add a service to config.yml:
services:
cache:
class: Doctrine\Common\Cache\ApcCache
And use it in your controller:
if ($fooString = $this->get('cache')->fetch('foo')) {
$foo = unserialize($fooString);
} else {
// do the work
$this... |
Should I use HttpRuntime.Cache? |
I'm a beginner in asp.net, and have a few question of Cache:
HttpRuntime.Cache only provides severals methods and I think I'm able to implement these methods with Dictionary by myself.
If HttpRuntime.Cache is much better than Dictionary, why some people would like to implement their own cache framework.
How about MS ... |
HttpRuntime.Cache only provides severals methods and I think I'm able
to implement these methods with Dictionary by myself.
You think wrong. HttpRuntime.Cache is much more than a simple dictionary. It offers thread-safety and cache expiration policies. It provides possibilities of using custom implementation and b... |
How do I view Android application specific cache? |
Is there any way to dynamically view the application specific cache in Android? I'm saving images to the cache (/data/data/my_app_package/cache) and I'm 99% sure they're saving there, but not sure how long they're staying around.
When I look in the cache using the DDMS File Explorer within Eclipse, it's always empty. ... |
Unless ADB is running as root (as it would on an emulator) you cannot generally view anything under /data unless an application which owns it has made it world readable. Further, you cannot browse the directory structure - you can only list files once you get to a directory where you have access, by explicitly enteri... |
Why doesn't perf report cache misses? |
According to perf tutorials, perf stat is supposed to report cache misses using hardware counters. However, on my system (up-to-date Arch Linux), it doesn't:
[joel@panda goog]$ perf stat ./hash
Performance counter stats for './hash':
869.447863 task-clock # 0.997 CPUs utilized
... |
On my system, an Intel Xeon X5570 @ 2.93 GHz I was able to get perf stat to report cache references and misses by requesting those events explicitly like this
perf stat -B -e cache-references,cache-misses,cycles,instructions,branches,faults,migrations sleep 5
Performance counter stats for 'sleep 5':
10573 ca... |
Using static keyword in objective-c when defining a cached variable |
I'm looking at the following apple example source code:
/*
Cache the formatter. Normally you would use one of the date formatter styles (such as NSDateFormatterShortStyle), but here we want a specific format that excludes seconds.
*/
static NSDateFormatter *dateFormatter = nil;
if (dateFormatter == nil) {
da... |
Static variables retain their assigned values over repeated calls to the function. They're basically like global values that are only "visible" to that function.
The initializer statement is only executed once however.
This code initializes dateFormatter to nil the first time the function is used. On every subsequent ... |
Where does Redis store the data |
I am using redis for pub/sub as well as for server side cache. I mean my app server has redis server running as one process (functioning as a cache as well) . I have several thin clients (running redis client) connected to this app server in pub/sub mode. I would like to know where redis stores the cache data ? in se... |
31
Redis is a (sort of) in-memory noSQL database; but I found that my copy (running on linux) dumps to /var/lib/redis/dump.rdb
Share
Improve this answer
Follow
answered Jun 6, 2015 at 15:50
... |
using guava cache without a load function |
My java app has a cache, and I'd like to swap out the current cache implementation and replace it with the guava cache.
Unfortunately, my app's cache usage doesn't seem to match the way that guava's caches seem to work. All I want is to be able to create an empty cache, read an item from the cache using a "get" metho... |
CacheBuilder.build() returns a non-loading cache. Just what you want. Just use
Cache<String, String> cache = CacheBuilder.newBuilder().build();
|
Caching Data in Web API |
I have the need to cache a collection of objects that is mostly static (might have changes 1x per day) that is avaliable in my ASP.NET Web API OData service. This result set is used across calls (meaning not client call specific) so it needs to be cached at the application level.
I did a bunch of searching on 'caching... |
Yes, output caching is not what you are looking for. You can cache the data in memory with MemoryCache for example, http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.aspx . However, you will lose that data if the application pool gets recycled. Another option is to use a distributed cache like... |
How can I prevent a Dockerfile instruction from being cached? |
In my Dockerfile I use curl or ADD to download the latest version of an archive like:
FROM debian:jessie
...
RUN apt-get install -y curl
...
RUN curl -sL http://example.com/latest/archive.tar.gz --output archive.tar.gz
...
ADD http://example.com/latest/archive2.tar.gz
...
The RUN statement that uses curl or ADD creat... |
A build-time argument can be specified to forcibly break the cache from that step onwards. For example, in your Dockerfile, put
ARG CACHE_DATE=not_a_date
and then give this argument a fresh value on every new build. The best, of course, is the timestamp.
docker build --build-arg CACHE_DATE=$(date +%Y-%m-%d:%H:%M:%S)... |
How to cache Django Rest Framework API calls? |
I'm using Memcached as backend to my django app. This code works fine in normal django query:
def get_myobj():
cache_key = 'mykey'
result = cache.get(cache_key, None)
if not result:
result = Product.objects.all().filter(draft=False)
cache.set(cache_key, result)
r... |
Ok, so, in order to use caching for your queryset:
class ProductListAPIView(generics.ListAPIView):
def get_queryset(self):
return get_myobj()
serializer_class = ProductSerializer
You'd probably want to set a timeout on the cache set though (like 60 seconds):
cache.set(cache_key, result, 60)
If you wa... |
How to invalidate cache data [OutputCache] from a Controller? |
Using ASP.Net MVC 3 I have a Controller which output is being cached using attributes [OutputCache]
[OutputCache]
public controllerA(){}
I would like to know if it is possible to invalidate the Cache Data (SERVER CACHE) for a Specific Controller or generally all the Cache data by calling another controller
public co... |
You could use the RemoveOutputCacheItem method.
Here's an example of how you could use it:
public class HomeController : Controller
{
[OutputCache(Duration = 60, Location = OutputCacheLocation.Server)]
public ActionResult Index()
{
return Content(DateTime.Now.ToLongTimeString());
}
public ... |
How do I set expiration on CSS, JS and Images? |
I have recently analysed my website with pagespeed addon on firebug. It suggested me to set expiration on CSS, JS and image files.
I am wondering, how do I do this?
|
This is the one I use to fix the exact same thing when I ran the PageSpeed Addon:
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
This goes into your .htaccess file.
Read up on this page for more information about how to set cache for additional file types ... |
How to find the size of the L1 cache line size with IO timing measurements? |
As a school assignment, I need to find a way to get the L1 data cache line size, without reading config files or using api calls. Supposed to use memory accesses read/write timings to analyze & get this info. So how might I do that?
In an incomplete try for another part of the assignment, to find the levels & size of... |
Allocate a BIG char array (make sure it is too big to fit in L1 or L2 cache). Fill it with random data.
Start walking over the array in steps of n bytes. Do something with the retrieved bytes, like summing them.
Benchmark and calculate how many bytes/second you can process with different values of n, starting from 1 a... |
Rails action caching with querystring parameters |
How can I cache my REST controller with Rails where my actions have query string parameters?
Example: GET /products/all.xml?max_price=200
Thx!
|
If you want to cache an action, based on all the query parameters (or say on nearly all of them), you can do:
caches_action :my_action, :cache_path => Proc.new { |c| c.params }
Or, maybe you want all but some params that you just use for Analytics (but that have no bearing on the records you're fetching):
caches_acti... |
Is it there any LRU implementation of IDictionary? |
I would like to implement a simple in-memory LRU cache system and I was thinking about a solution based on an IDictionary implementation which could handle an hashed LRU mechanism.
Coming from java, I have experiences with LinkedHashMap, which works fine for what I need: I can't find anywhere a similar solution for .N... |
There is nothing in the base class libraries that does this.
On the free side, maybe something like C5's HashedLinkedList would work.
If you're willing to pay, maybe check out this C# toolkit. It contains an implementation.
|
NGINX caching proxy fails with SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure |
NGINX acting as a caching proxy encounters problems when fetching content from CloudFront server over HTTPS:
This is the extract from the NGINX's error log:
2014/08/14 16:08:26 [error] 27534#0: *11560993 SSL_do_handshake() failed (SSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure) w... |
I had the exactly same problem and spent a couple of hours...
I guess you are using older version of nginx (lower than 1.7)?
In nginx 1.7 you can use this directive:
proxy_ssl_server_name on;
This will force nginx to use SNI
Also, you should set the SSL protocols:
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
For earl... |
Does SQLAlchemy support caching? |
Does SQLAlchemy support some kind of caching so if I repeatedly run the same query it returns the response from cache instead of querying the database? Is this cache automatically cleared when the DB is updated?
Or what's the best way to implement this on a CherryPy + SQLAlchemy setup?
|
We have a pretty comprehensive caching solution, as an example in conjunction with embedded hooks, in 0.6. It's a recipe to subclass Query, make it aware of Beaker, and allow control of query caching for explicit queries as well as lazy loaders via query options.
I'm running it in production now. The example itself... |
Amazon Cloudfront Cache-Control: no-cache header has no effect after 24 hours |
I'm hosting a static website in S3 and using Cloudfront to cache files. I've essentially got 3 files with the following headers:
index.html (Cache-Control: no-cache)
app.js (Cache-Control: max-age=63072000, public)
style.css (Cache-Control: max-age=63072000, public)
My html file uses query string parameters that get... |
Verify that the CloudFront distribution's Minimum TTL is set to 0. If it's set to any other value, CloudFront won't respect the no-cache header and will still cache the file for the Minimum TTL. More details about the caching directives can be found here:
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGui... |
Caching in C#/.Net |
I wanted to ask you what is the best approach to implement a cache in C#? Is there a possibility by using given .NET classes or something like that? Perhaps something like a dictionary that will remove some entries, if it gets too large, but where whose entries won't be removed by the garbage collector?
|
If you're using ASP.NET, you could use the Cache class (System.Web.Caching).
Here is a good helper class: c-cache-helper-class
If you mean caching in a windows form app, it depends on what you're trying to do, and where you're trying to cache the data.
We've implemented a cache behind a Webservice for certain methods
... |
Website needs force refresh after deploy |
After deploying a new version of a website the browser loads everything from its cache from the old webpage until a force refresh is done. Images are old, cookies are old, and some AJAX parts are not working.
How should I proceed to serve the users with the latest version of the page after deploy?
The webpage is an A... |
You can append a variable to the end of each of your resources that changes with each deploy. For example you can name your stylesheets:
styles.css?id=1
with the id changing each time.
This will force the browser to download the new version as it cannot find it in its cache.
|
How to limit the maximum size of a Map by removing oldest entries when limit reached [closed] |
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
... |
You can use LinkedHashMap like this
You can remove by LRU or FIFO.
public static <K, V> Map<K, V> createLRUMap(final int maxEntries) {
return new LinkedHashMap<K, V>(maxEntries*10/7, 0.7f, true) {
@Override
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
return size() > ma... |
Caffeine versus Guava cache |
According to these micro benchmarks it turns out that Caffeine is a way faster than Guava cache in both read and write operations.
What is the secret of Caffeine implementation? How it differs from the Guava Cache?
Am I right that in case of timed expiration Caffeine use a scheduled executor to perform appropriate mai... |
The main difference is because Caffeine uses ring buffers to record & replay events, whereas Guava uses ConcurrentLinkedQueue. The intent was always to migrate Guava over and it made sense to start simpler, but unfortunately there was never interest in accepting those changes. The ring buffer approach avoids allocatio... |
Does express.static() cache files in the memory? |
In ExpressJS for NodeJS, we can do the following:
app.use(express.static(__dirname + '/public'));
to serve all the static CSS, JS, and image files. My questions are these:
1) When we do that, does Express automatically cache the files in the server's memory or does it read from the hard disk every time one of the res... |
The static middleware does no server-side caching. It lets you do two methods of client-side caching: ETag and Max-Age:
If the browser sees the ETag with the page, it will cache it. The next time the browser loads the page it checks for the ETag number changes. If the file is exactly the same, and so is its ETag - t... |
How to clear/delete cache in NextJs? |
I have a product page at /products/[slug].js
and I use Incremental Static Generation for a wordpress/graphql site:
export async function getStaticProps(context) {
const {params: { slug }} = context
const {data} = await client.query(({
query: PRODUCT_SLUG,
variables: { slug }
}));
ret... |
52
To clear the cache in Next.js app, follow these steps:
Stop the development server or any running Next.js processes.
Locate the root directory of your Next.js project.
Delete the .next directory. You can do this using the command line or file explorer.
Info: Once the .... |
Does it make sense to have max-age and s-maxage in the Cache-Control HTTP header? |
Considering that max-age applies to all the caches, and s-maxage only applies to shared caches (proxy and gateway cache)....
Does it make sense to use both directives in a non-expirable and public page?
Controller pseudo-code:
w = Response();
w.setPublic();
w.setMaxAge("1 year");
w.setShareMaxAge("1 year");
return w;... |
From HTTP Header Field Definitions:
14.9.3 Modifications of the Basic Expiration Mechanism
...
s-maxage
If a response includes an s-maxage directive, then for a shared cache (but not for a private cache), the maximum age specified by this directive overrides the maximum age specified by either the max-age directive o... |
Best practice to record large amount of hits into MySQL database |
Well, this is the thing. Let's say that my future PHP CMS need to drive 500k visitors daily and I need to record them all in MySQL database (referrer, ip address, time etc.). This way I need to insert 300-500 rows per minute and update 50 more. The main problem is that script would call database every time I want to i... |
500k daily it's just 5-7 queries per second. If each request will be served for 0.2 sec, then you will have almost 0 simultaneous queries, so there is nothing to worry about.
Even if you will have 5 times more users - all should work fine.
You can just use INSERT DELAYED and tune your mysql.
About tuning: http://www.d... |
Is it OK to use HttpRuntime.Cache outside ASP.NET applications? |
Scott Hanselman says yes.
Adding System.Web to your non-web project is a good way to get folks to panic. Another is adding a reference to Microsoft.VisualBasic in a C# application. Both are reasonable and darned useful things to do, though.
MSDN says no.
The Cache class is not intended for use outside of ASP.NET ap... |
I realize this question is old, but in the interest of helping anyone who finds this via search, its worth noting that .net v4 includes a new general purpose cache for this type of scenario. It's in the System.Runtime.Caching namespace:
https://msdn.microsoft.com/en-us/library/dd997357(v=vs.110).aspx
The static refere... |
How to clear all cached items in Oracle |
I'm tuning SQL queries on an Oracle database. I want to ensure that all cached items are cleared before running each query in order to prevent misleading performance results. I clear out the shared pool (to get rid of cached SQL/explain plans) and buffer cache (to get rid of cached data) by running the following comma... |
Flushing the shared pool should do it, but Tom Kyte lists a couple reasons below why you may not get the result you are expecting in some cases:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6349391411093
|
How can I clear rails cache after deploy to heroku? |
I applied cache to my heroku rails app and it works well.
But everytime I deploy to heroku, I also want to clear cache automatically.
so I googled and I found this.
task :after_deploy, :env, :branch do |t, args|
puts "Deployment Complete"
puts "Cleaning all cache...."
FileUtils.cd Rails.root do
sh %{herok... |
43
Rails has a built in rake task:
rake tmp:clear
Share
Improve this answer
Follow
answered May 28, 2013 at 18:29
gabeodessgabeodess
2,0762121 silver badges1616 bronze badges
0
... |
Glide not updating image android of same url? |
I have the same url for an image. When I update this image more than one time it shows the previous image. The image and picture version on the server is updated but Glide is not showing the new image.I want to get new image every time and cache it .
Glide.with(context)
.load(Constants.COPY_LINK_BASE_URL + in... |
31
//Use bellow code, it work for me.Set skip Memory Cache to true. it will load the image every time.
Glide.with(Activity.this)
.load(theImagePath)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(myImageViewPhoto);
Share
Improve this ... |
How to force Apache to use manually pre-compressed gz file of CSS and JS files? |
I have simple question. I have webdirectory /css and inside is file style.css. I have manually gzipped this file and saved it as style.css.gz. I want to save CPU cycles to not have CSS file compressed at each request. How do I configure Apache to look for this .gz file and serve it instead of compressing .css file ove... |
Some RewriteRule should handle that quite well.
In a Drupal configuration file I found:
# AddEncoding allows you to have certain browsers uncompress information on the fly.
AddEncoding gzip .gz
#Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
Rewrite... |
Symfony2 disable cache? |
Is there a way to disable the caching function in Symfony2? I tried to find the setting in the config* and parameters.ini files and I searched a lot. Ok, I found a few solutions, but nothing for the latest version (Symfony2).
WHY? Because I want to test new templates and functions without clearing the app/cache* all t... |
I'm assuming you're using the Twig engine, (the default templating engine for Symfony2). To disable caching in twig, so that you do not have to keep clearing the cache like so:
rm -rf app/cache/*
Navigate to your app config file (by defualt will be located in ../app/config/config.yml from your root directory). Scroll... |
Fastest way to loop through a 2d array? |
I just stumbled upon this blog post about cache algorithms.
The author shows two code samples that loop through a rectangle and compute something (my guess is the computing code is just a placeholder).
On one of the examples, he scans the rectangle vertically, and on the other horizontally. He then says the second is ... |
Cache coherence. When you scan horizontally, your data will be closer together in memory, so you will have less cache misses and thus performance will be faster. For a small enough rectangle, this won't matter.
|
OutputCache setting inside my asp.net mvc web application. Multiple syntax to prevent caching |
I am working on an asp.net MVC web application and I need to know if there are any differences when defining the OutputCache for my action methods as follow:-
[OutputCache(Duration = 0, Location = OutputCacheLocation.Client, VaryByParam = "*")]
VS
[OutputCache(NoStore = true, Duration = 0, Location="None", VaryByPara... |
The NoStore property is used to inform proxy servers and browser that they should not store a permanent copy of the cached content by setting Cache-Control: no-store within the request header.
Duration simply specifies how long the content of the controller action should be cached, e.g. 10seconds. This will set the Ca... |
Looking for a very simple Cache example |
I'm looking for a real simple example of how to add an object to cache, get it back out again, and remove it.
The second answer here is the kind of example I'd love to see...
List<object> list = new List<Object>();
Cache["ObjectList"] = list; // add
list = ( List<object>) Cache["ObjectList"]; // retri... |
.NET provides a few Cache classes
System.Web.Caching.Cache - default caching mechanizm in ASP.NET. You can get instance of this class via property Controller.HttpContext.Cache also you can get it via singleton HttpContext.Current.Cache. This class is not expected to be created explicitly because under the hood it use... |
Clearing the pipeline cache with Gitlab CI |
Is it possible to invalidate or clear a pipeline cache with the Gitlab CI after a pipeline completes?
My .gitlab-ci.yml file has the following global cache definition
cache:
key: "%CI_PIPELINE_ID%"
paths:
- './msvc/Project1`/bin/Debug'
- './msvc/Project2`/bin/Debug'
- './msvc/Project3`/bin/Debug'
The ... |
It's not a perfect solution, but we ended up creating a cleanup job at the end of our .gitlab-ci.yaml file that deletes the cache directory from the filesystem.
This way, each pipeline gets its own unique cache, without cluttering up the file system over time.
cleanup_job:
stage: cleanup
script:
- echo "Cleani... |
How do you force an iPad home screen bookmarked web app to refresh? |
I've run into a problem where I add a web app to my iPad home screen (iOS 5.0.1 iPad 2), and when I open it it appears to be caching something behind the scenes, independent of Safari.
I've cleared out everything from Safari that's available in Settings (Clear History and Clear Cookies & Data), and when I navigate to... |
I think I found a workaround:
The new version of the site only appears when the index.html file changes.
(the first file to be loaded)
If you leave the index.html and only change some js in other files then the site doesn't load the new version.
|
Django Sessions |
I'm looking at sessions in Django, and by default they are stored in the database. What are the benefits of filesystem and cache sessions and when should I use them?
|
25
The filesystem backend is only worth looking at if you're not going to use a database for any other part of your system. If you are using a database then the filesystem backend has nothing to recommend it.
The memcache backend is much quicker than the database backend, b... |
Why are immutable objects in hashmaps so effective? |
So I read about HashMap. At one point it was noted:
"Immutability also allows caching the hashcode of different keys which makes the overall retrieval process very fast and suggest that String and various wrapper classes (e.g., Integer) provided by Java Collection API are very good HashMap keys."
I don't quite under... |
String#hashCode:
private int hash;
...
public int hashCode() {
int h = hash;
if (h == 0 && count > 0) {
int off = offset;
char val[] = value;
int len = count;
for (int i = 0; i < len; i++) {
h = 31*h + val[off++];
}
hash = h;
}
return h;
}
... |
Set cache to files in Firebase Storage |
I have a PWA running on Firebase. My image files are hosted on the Firebase Storage. I've noticed my browser doesn't save cache for files loaded from the storage system. The browser requests the files for every page refresh. It causes unnecessary delay and traffic.
My JS script loads the files from the Firebase Stora... |
cacheControl for Storage : https://firebase.google.com/docs/reference/js/firebase.storage.SettableMetadata#cacheControl
You'll have better serving with Hosting, and deployment with the firebase CLI is extremely simple. I think by default the Cache-Control on images in Hosting is 2 hours, and you can increase it glob... |
Where and how to check that hibernate cache really works |
I am new in the hibernate's cache area.
What is the easiest way to check that the cache really works?
Does hibernate gnerate the same sql statements when cache is on?
Should it be any folder/file in filesystem with stored data (second-level cache)?
How to check how much cache is currently used?
Regards,
Marcin
|
You can enable Hibernate statistics generation be setting hibernate.generate_statistics property to true. Then you can monitor cache hit/miss count via SessionFactory.getStatistics().
Also, when SQL logging is enabled you can analyze cache behaviour by presence or absense of particular SQL queries.
It depends on man... |
Redis or Ehcache? |
Which is better suited for the following environment:
Persistence not a compulsion.
Multiple servers (with Ehcache some cache sync must be required).
Infrequent writes and frequent reads.
Relatively small database (very less memory requirement).
I will pour out what's in my head currently. I may be wrong about these... |
You can think Redis as a shared data structure, while Ehcache is a memory block storing serialized data objects. This is the main difference.
Redis as a shared data structure means you can put some predefined data structure (such as String, List, Set etc) in one language and retrieve it in another language. This is us... |
Prevent caching of HTML page [duplicate] |
This question already has answers here:
How do we control web page caching, across all browsers?
(30 answers)
Closed 7 years ago.
The community reviewed whether to reopen this questio... |
The values you have there are OK, but meta http-equiv is highly unreliable. You should be using real HTTP headers (the specifics of how you do this will depend on your server, e.g. for Apache).
|
How to tell whether Haskell will cache a result or recompute it? |
I noticed that sometimes Haskell pure functions are somehow cached: if I call the function twice with the same parameters, the second time the result is computed in no time.
Why does this happen? Is it a GHCI feature or what?
Can I rely on this (ie: can I deterministically know if a function value will be cached)?
Ca... |
primes, in your code, is not a function, but a constant, in haskellspeak known as a CAF. If it took a parameter (say, ()), you would get two different versions of the same list back if calling it twice, but as it is a CAF, you get the exact same list back both times;
As a ghci top-level definition, primes never become... |
Temporal vs Spatial Locality with arrays |
I am a little confused on the meanings of spatial and temporal locality. I'm hoping by looking at it with an array example it will help me understand it better.
In an example like this:
A[0][1], A[0][2], A[0][3].... etc
Does this demonstrate temporal locality? I see the same row is accessed many times but at different... |
Spatial and temporal locality describe two different characteristics of how programs access data (or instructions). Wikipedia has a good article on locality of reference.
A sequence of references is said to have spatial locality if things that are referenced close in time are also close in space (nearby memory addres... |
A Cache Efficient Matrix Transpose Program? |
So the obvious way to transpose a matrix is to use :
for( int i = 0; i < n; i++ )
for( int j = 0; j < n; j++ )
destination[j+i*n] = source[i+j*n];
but I want something that will take advantage of locality and cache blocking. I was looking it up and can't find code that would do this, but I'm told it sho... |
You're probably going to want four loops - two to iterate over the blocks, and then another two to perform the transpose-copy of a single block. Assuming for simplicity a block size that divides the size of the matrix, something like this I think, although I'd want to draw some pictures on the backs of envelopes to be... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.