Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
Caching application data in memory: MVC Web API |
I am writing an MVC webAPI that will be used to return values that will be bound to dropdown boxes or used as type-ahead textbox results on a website, and I want to cache values in memory so that I do not need to perform database requests every time the API is hit.
I am going to use the MemoryCache class and I know I... |
You can use the global.asax appplication start method to initialize resources.
Resources which will be used application wide basically.
The following link should help you to find more information:
http://www.asp.net/web-forms/tutorials/data-access/caching-data/caching-data-at-application-startup-cs
Hint:
If you use in... |
How can I get control of Google App Engine caching behavior in WebKit (etags gone crazy)? |
Situation: running a Google App Engine site with my static content's default_expiration set to "14d"
Problem: in Chrome and Safari, visiting a URL (not reloading, just putting the cursor in the address bar and hitting Enter), causes a ton of requests to be fired with If-None-Match headers. The responses are always 304... |
While I don't believe there is any way to control the etags header behavior for GAE, this is caused by a bug in WebKit that causes all static content to be re-downloaded when receiving a 302 redirect after a POST request.
Once WebKit fixes this bug, the issue should go away.
If you must, you can temporarily work aroun... |
How to cache a fragment view |
I'd like to cache a fragment view. My Activity has swipeable tabs and each tab calls a different fragment. But when i swipe between tabs the transition seems a quite slow because of the destruction of the fragment view, that is rebuilded during the swipe operation. Does anyone know how can i cache the view of each fra... |
This is because internally by default the pager loads a maximum of 3 pages (fragments) at the time:
the one displaying, previous and next so if you have 5 fragments this will happen while you move from first to last: (where x is a loaded fragment)
xx000
->
xxx00
->
0xxx0
->
00xxx
->
000xx
Try using
myPager.setOffscre... |
Memcached vs SQL Server cache |
I've been reading a lot of articles that suggest putting a Memcached (or Velocity, etc) in front of a database is more efficient than hitting the database directly. It will reduce the number of hits on the database by looking up the data in a memory cache, which is faster than hitting the database.
However, SQL Serve... |
So if SQL Server has it's own cache, what is the benefit of an external Memcached (or similar) server?
Yes SQL Server has its own cache but he caches only:
- Query plans
- pages from the database files
but he does NOT cache:
- results from a query
e.g. you have a complex query which uses some aggregation on a lot ... |
Cache NPM dependencies on Jenkins pipeline |
We all know that downloading dependencies with npm can be very time consuming, specially when we are limited to old npm versions.
For me, as a developer, this wasn't such a big deal because I had to do this very few times on my local development machine and everything worked with the node_modules cache in my project's... |
5
NPM has a global cache stored in ~/.npm
Share
Improve this answer
Follow
answered Jul 26, 2018 at 16:14
StevenSteven
5111 gold badge22 silver badges33 bronze badges
1
... |
Hashing a python function to regenerate output when the function is modified |
I have a python function that has a deterministic result. It takes a long time to run and generates a large output:
def time_consuming_function():
# lots_of_computing_time to come up with the_result
return the_result
I modify time_consuming_function from time to time, but I would like to avoid having it run a... |
If I understand your problem, I think I'd tackle it like this. It's a touch evil, but I think it's more reliable and on-point than the other solutions I see here.
import inspect
import functools
import json
def memoize_zeroadic_function_to_disk(memo_filename):
def decorator(f):
try:
with open(... |
Donut caching _Layout with mvcdonutcaching ASP.NET MVC |
In my ASP.NET MVC project, I have a login submenu in the navigation menu of my shared _Layout.cshtml file, displaying user info if the user is logged in, or signup/login options if not. The login submenu is a partial view in my shared folder named _LoginPartial:
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenti... |
1
I ran into the exact same thing but solved it after noticing that I had inadvertently used [OutputCache] instead of [DonutOutputCache]!
User error. Works in _Layout beautifully. Please double-check that you are using the proper [DonutOutputCache] attribute.
Share
... |
OSCache vs. EHCache |
Never used a cache like this before. The problem is that I want to load 500,000 + records out of a database and do some selecting/filtering wicked fast.
I'm thinking about using a cache, and preliminarily found EHCache and OSCache, any opinions?
|
They're both pretty solid projects. If you have pretty basic caching needs, either one of them will probably work as well as the other.
You may also wish to consider doing the filtering in a database query if it's feasible. Often, using a tuned query that returns a smaller result set will give you better performance... |
how to clear cache in CachedNetworkImage flutter |
i dont want to store image in cache.. iam using CachedNetworkImage for image loading..
I want know is there any option to remove or do not store image in cache like picasso..
my code:
var annotatedImg = CachedNetworkImage(
fit: BoxFit.fill,
imageUrl: Constants.IMAGE_BASE_URL + widget._fileId + Constants.CO... |
Firstly add the package (flutter_cache_manager) to pubspec.yaml file as following:
dependencies:
flutter:
sdk: flutter
flutter_cache_manager: ^1.1.3
After a day, I found the solution. Use the DefaultCacheManager object by calling emptyCache() method, this clears the cache data.
DefaultCacheManager manager = new Defaul... |
HTTP response caching |
I want to ensure that my servet's response is never cached by the broswer, such that even if two identical requests are made (a nanosecond apart), the server is always contacted. Is this the correct way to achieve this:
class MyServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpSer... |
No, that's not the correct way. Here is the correct way:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Proxies.
You'll probably see someone else suggesting other entries/attribute... |
How do you make your Java application memory efficient? |
How do you optimize the heap size usage of an application that has a lot (millions) of long-lived objects? (big cache, loading lots of records from a db)
Use the right data type
Avoid java.lang.String to represent other data types
Avoid duplicated objects
Use enums if the values are known in advance
Use object p... |
You don't say what sort of objects you're looking to store, so it's a little difficult to offer detailed advice. However some (not exclusive) approaches, in no particular order, are:
Use a flyweight pattern wherever
possible.
Caching to disc. There are
numerous cache solutions for
Java.
There is some debate as to whe... |
How to get list of all cached items by key in Laravel 5? |
The Cache class in laravel has methods such as get('itemKey') to retrieve items from the cache, and remember('itemKey', ['myData1', 'myData2']) to save items in the cache.
There is also a method to check if an item exists in the cache: Cache::has('myKey');
Is there any way, (when using the file-based cache driver), to... |
There is no way to do that using Cache facade. Its interface represents the functionality that all underlying storages offer and some of the stores do not allow listing all keys.
If you're using the FileCache, you could try to achieve that by interacting with the underlying storage directly. It doesn't offer the metho... |
Disabling AngularJS $http cache |
I'm trying to disable the cache in my AngularJS app, but it isn't working with the following code:
$http.get("myurl",{cache:false})
When I use "myurl&random="+Math.random(), the cache is disabled; but, I'd like a different approach.
|
This is already answered here.
Pasting code snippet from the link for your reference.
myModule.config(['$httpProvider', function($httpProvider) {
//initialize get if not there
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
// Answer edited to incl... |
How to clear DNS cache in Firefox Quantum? |
Like in the title, how to clear that cache?
There are some plugins, but its installation is disabled for Firefox Quantum...
https://addons.mozilla.org/en-US/firefox/addon/dns-flusher/
https://addons.mozilla.org/en-us/firefox/addon/clear-dns-cache/
|
You can take look at about:networking#dns which directly lets you clear the cache.
And Where does Firefox keep cached DNS responses? had already been answered by Firefox's Support Team.
ScreenShot:
By the way for chrome it is chrome://net-internals/#dns
|
Turn OFF Cache for specific file with Apache |
I have a page on a site which uses random() twig, in Firefox and Chrome it is prevented from working because it gets cached as soon as the page loads.
Is there a way to turn off caching of a particular file via the Apache configs, lets call it default.html or even better just turn off caching for the script part of t... |
Figured it out, to target a specific file (in this case index.php), add this code to the bottom of .htaccess
<Files index.php>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</File... |
How do I specify a wildcard in the HTML5 cache manifest to load all images in a directory? |
I have a lot of images in a folder that are used in the application. When using the cache manifest it would be easier maintenance wise if I could specify a wild card to load all the images or files in a certain directory to be cached.
E.g.
CACHE MANIFEST
# 2011-11-3-v0.1.8
#--------------------------------
# Pages
#--... |
I don't think it works that way. You'll have to specify all of the images one by one, or have a simple PHP script to loop through the directory and output the file (with the correct text/cache-manifest header of course).
|
How to disable cache in wordpress |
I am creating a website, but I needed to do refresh several time to see the changes I made in website. Is there any option that I can use to disable cache in WordPress?
|
41
put below code in your wp-config.php file.
define('WP_CACHE', false);
Share
Improve this answer
Follow
answered Sep 13, 2017 at 11:20
Akshay ShahAkshay Shah
3,40622 gold badges2020 sil... |
How to cache data on server in asp.net mvc 4? |
I am working on mvc4 web application. I want to cache some database queries results and views on server side. I used-
HttpRuntime.Cache.Insert()
but it caches the data on client side. Please help.
|
I'm using MemoryCache to store query results, and it's working fine so far.
Here are a few links that I've used to implement it.
- Using MemoryCache in .NET 4.0 (codeproject)
- Using MemoryCache in .NET 4.0 (blog entry)
As I read them now, I find them not that clear, so maybe there is a better link that I've lost som... |
Website html doesnt update for users because of cache |
I am making a website and am running into an issue with website cache for my users. I develop my website and have set chrome developer tools to disable cache for my website for development. The issue is when i release a new change to prod all my users don't get the update because of their browser cache. When i delete ... |
What are the resources that are being cached? I suspect js/css files, a good way to handle this is to add a query param with a version to the path of those resources in order to force the browser to load the new file if the version changed, something like this:
<script type="text/javascript" src="your/js/path/file.js?... |
Multiple threads and CPU cache |
I am implementing an image filtering operation in C using multiple threads and making it as optimized as possible. I have one question though: If a memory is accessed by thread-0, and concurrently if the same memory is accessed by thread-1, will it get it from the cache ? This question stems from the possibility that ... |
In general it is a bad idea to share overlapping memory regions like if one thread processes 0,2,4... and the other processes 1,3,5... Although some architectures may support this, most architectures will not, and you probably can not specify on which machines your code will run on. Also the OS is free to assign your ... |
Cache a static file in memory forever on Nginx? |
I have Nginx running in a Docker container, and it serves some static files. The files will never change at runtime - if they actually do change, the container will be stopped, the image will be rebuilt, and a new container will be started.
So, to improve performance, it would be perfect if Nginx would read the static... |
Operating system does in memory caching by default. It's called page cache. In addition, you can enable sendfile to avoid copying data between kernel space and user space.
|
Difference between Memcache, APC, XCache and other alternatives I've not heard of |
At work, we've recently started designing an application to me "large scale" (we're engineering for the potential to serve up many millions of hits a day). One of the senior devs and the sysadmin have set up memcache on the server.
As I understand it, Memcache will hold query results and certain tables in memory fo... |
First, a list of opcode cachers for php.
Second Memcache/MemcacheD is not an Opcode Cacher. It is a distributed memory caching system. It does not improve the speed/performance of your PHP code. It can be used to store data only.
APC, EAccelerator, XCache and the others are non distributed, meaning you can only store ... |
HTTP Expires header not respected by browser? |
I have a situation where my (embedded) web server is sending Expires header, but the browser does not seem to respect the header setting, i.e., if I refresh the page, the browser requests the resources that are supposed to be cached. Following are the headers that are getting exchanged:
https://192.168.1.180/scgi-bin... |
18
The browser ignores the Expires header if you refresh the page. It always checks whether the cache entry is still valid by contacting the web server. Ideally, it will use the If-Modified-Since request header so that the server can return '304 Not modified' if the cache e... |
How to cache static files in ASP.NET Core? |
I can't seem to enable caching of static files in ASP.NET Core 2.2. I have the following in my Configure:
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
app.UseCors(...);
}
else {
app.UseHsts();
}
app.UseHttps... |
19
This is working in ASP.NET Core 2.2 to 3.1:
I know this is a bit similar to Fredrik's answer but you don't have to type literal strings in order to get the cache control header
app.UseStaticFiles(new StaticFileOptions()
{
HttpsCompression = Microsoft.AspNetCore.Http.... |
Which cache-coherence-protocol does Intel and AMD use? |
For my bachelor thesis I have to analyse the effecs of False Sharing on multicore systems. So looking for the different cache-coherence-protocol-types I have come across on Wikipedia that Intel has developed the MESIF cache-coherence-protocol, but there is no information that Intel also uses this.
Looking at the manua... |
Intel uses MESIF protocol (http://www.realworldtech.com/common-system-interface/5/, https://en.wikipedia.org/wiki/MESIF_protocol) in QuickPath and AMD uses MOESI protocol (https://en.wikipedia.org/wiki/MOESI_protocol, http://www.m5sim.org/MOESI_hammer) with or without Probe Filter in HyperTransport. But these protocol... |
Laravel: how to separate cache and session into different redis database? |
I want to put session and cache data into redis. This is my configuration in database.php:
'redis' => array(
'cluster' => false,
'default' => array(
'host' => '192.168.56.101',
'port' => 6379,
'database' => 0,
),
'session' => array(
'host' => '192.168.56.1... |
9
Introduction
Here is my note, for some other guy who running in to this problem, I think this is should be in the docs.
By default, redis gives you 16 separate databases, but laravel out of the box will try to use database 0 for both sessions and cache.
Our solution is ... |
Combine Sliding and Absolute Expiration |
I want to use System.Runtime.Caching.MemoryCache for caching some of my objects. I want to be sure that the object is refreshed once a day (absolute expiration) but I also want to make it expire if it hasn't been used in the last hour (sliding expiration).
I try to do:
object item = "someitem";
var cache = MemoryCache... |
You can implement both schemes cache expiration by using CacheEntryChangeMonitor.
Insert a cache item without information with absolute expiration, then create a empty monitorChange with this item and link it with a second cache item, where you will actually save a slidingTimeOut information.
object data = new... |
spring 3.1 @Cacheable example |
I am new to spring annotation and i want to create a sample example which shows the use of @Cacheable annotation in spring 3.1 does any one have guidance to create this ?
|
Hope following link may be helpful to you... A sample application.
Also have a look on Spring's documentation for cache abstraction and spring source blog post.
|
Cache validator for Google Webfonts |
So I'm creating an ultra optimized site, and my page load speed with https://developers.google.com/speed/pagespeed/ is 99 (out of 100).
The only thing keeping me away from full hundred is this:
By specifying a cache validator - a Last-Modified or ETag header - you ensure that the validity of cached resources can effi... |
You can't do anything about it. You can't control what headers google server sends.
I would even go so far as to say it is reporting a false positive that you should fix.
http://redbot.org/?uri=http%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DOpen%2BSans%3A400%2C800
As you can see the resource is cached, has a max a... |
Hibernate-like framework for C++ [closed] |
Closed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions see... |
Try LiteSQL and Hiberlite and see if they can be of use to you.
|
Why is EhCacheProvider deprecated? |
I am configuring my hibernate project to use a 2nd-level cache provider, so that I can take advantage of query caching.
I added a dependency to ehcache:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.2.0</version>
</dependency>
I think that the provid... |
What gives? Is there an up-to-date replacement provider that I can use?
They have been deprecated in favor of the classes implementing the new Hibernate 3.3/3.5 SPI with its CacheRegionFactory. These implementations are respectively:
net.sf.ehcache.hibernate.EhCacheRegionFactory
net.sf.ehcache.hibernate.SingletonEh... |
@Caching With Multiple Keys |
I have a service that takes in a DTO and returns some result:
@Override
public int foo(Bar bar) {
....
}
Bar is as follows (simplified):
public class Bar {
public int id;
public String name;
public String baz;
@Override
public int hashCode() {
//this is already being defined for somet... |
Yes, you can specify using a Spring-EL expression along these lines:
@Override
@Cacheable(key="#bar.name.concat('-').concat(#bar.id)")
public int foo(Bar bar) {
....
}
or define a modified hashCode on bar and call that:
@Override
@Cacheable(key="#bar.hashCodeWithIdName")
public int foo(Bar bar) {
....
}
|
C#: How to implement a smart cache |
I have some places where implementing some sort of cache might be useful. For example in cases of doing resource lookups based on custom strings, finding names of properties using reflection, or to have only one PropertyChangedEventArgs per property name.
A simple example of the last one:
public static class Cache
{
... |
You could wrap each of your cached items in a WeakReference. This would allow the GC to reclaim items if-and-when required, however it doesn't give you any granular control of when items will disappear from the cache, or allow you to implement explicit expiration policies etc.
(Ha! I just noticed that the example give... |
How to store PHP sessions in APC Cache? |
Storing sessions in disk very slow and painful for me. I'm having very high traffic. I want to store session in Advanced PHP Cache, how can I do this?
|
I tried to lure better answers by offering 100 points as a bounty, but none of the answers were really satisfying.
I would aggregate the recommended solutions like this:
Using APC as a session storage
APC cannot really be used as a session store, because there is no mechanism available to APC that allows proper locki... |
Aggressive JavaScript caching |
I've run into a problem where I make changes to a few JavaScript files that are referenced in an HTML file, but the browser doesn't see the changes. It holds onto the copy cached in the browser, even though the web server has a newer version.
Not until I force the browser to clear the cache do I see the changes.
Is th... |
We append a product build number to the end of all Javascript (and CSS etc.) like so:
<script src="MyScript.js?4.0.8243">
Browsers ignore everything after the question mark but upgrades cause a new URL which means cache-reload.
This has the additional benefit that you can set HTTP headers that mean "never cache!"
|
calculate the effective access time |
This is a paragraph from Operating System Concepts, 9th edition by Silberschatz et al:
The percentage of times that the page number of interest is found in
the TLB is called the hit ratio. An 80-percent hit ratio, for example,
means that we find the desired page number in the TLB 80 percent of
the time. If it t... |
33
In the case that the page is found in the TLB (TLB hit) the total time would be the time of search in the TLB plus the time to access memory, so
TLB_hit_time := TLB_search_time + memory_access_time
In the case that the page is not found in the TLB (TLB miss) the total t... |
Angular Template cache not working |
I have a project using gulp and angular. I want to click a button and a pop up containing the html to show.
In the build.js file i have the following code:
gulp.task('templates', function() {
gulp.src(['!./apps/' + app + '/index.html', './apps/' + app + '/**/*.html'])
.pipe(plugins.angularTemplatecache('template... |
You have to also specify the templates module as a dependency of your module. For example:
angular.module('myApp', ['templates', 'ngDialog'])
Hope this helps.
|
Does the UIImage Cache image? |
UIImage *img = [[UIImage alloc] initWithContentsOfFile:@"xx.jpg"]
UIImage *img = [UIImage imageNamed:@"xx.jpg"]
In the second type will the image get cached ?
Whereas the in the first type the images doesn't get cached?
|
The -initWithContentsOfFile: creates a new image without caching, it's an ordinary initialization method.
The +imageNamed: method uses cache. Here's a documentation from UIImage Reference:
This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a ma... |
Avoiding 301 redirect caching |
This is a follow up question to Using 301/303/307 redirects for dynamic short urls, where I try to determine the best method for implementing short url redirection when the destination url will change on a frequent basis.
While it seems that 301 and 307 redirects both perform the same way, the issue that concerns me i... |
Don't try to avoid 301 caching. If you don't want any user agent to cache your redirect, then simply don't use a 301 redirect. In other words, 301 caching is here to stay, and semantically, it's a permanent redirect, so if you're planning to change the destination URL, 301 is not the right status code to use. On the o... |
Using Guava for high performance thread-safe caching |
I am trying to implement a high performance thread-safe caching. Here is the code I have implemented. I don't want any on demand computing. Can I use cache.asMap() and retrieve the value safely? Even if the cache is set to have softValues?
import java.io.IOException;
import java.util.concurrent.ConcurrentMap;
im... |
32
Guava contributor here:
Yes, that looks just fine, although I'm not sure what the point is of wrapping the cache in another object. (Also, Cache.getIfPresent(key) is fully equivalent to Cache.asMap().get(key).)
Share
Improve this answer
... |
IIS 7.5 and images not being cached |
I cannot get the image files to cache. I have tried everything that I have found on this site and others and still cannot get them to cache.
Web config setting that I have tried
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
<httpProtocol a... |
The following should cause the browsers to cache your images:
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" />
</staticContent>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="public" />
</customHeaders>
</httpProtocol>
The <caching>...</... |
How to cache results in scala? |
This page has a description of Map's getOrElseUpdate usage method:
object WithCache{
val cacheFun1 = collection.mutable.Map[Int, Int]()
def fun1(i:Int) = i*i
def catchedFun1(i:Int) = cacheFun1.getOrElseUpdate(i, fun1(i))
}
So you can use catchedFun1 which will check if cacheFun1 contains key and return value as... |
15
See the Memo pattern and the Scalaz implementation of said paper.
Also check out a STM implementation such as Akka.
Not that this is only local caching so you might want to lookinto a distributed cache or STM such as CCSTM, Terracotta or Hazelcast
Share
Impr... |
Prevent Caching in SQL Server |
Having looked around the net using Uncle Google, I cannot find an answer to this question:
What is the best way to monitor the performance and responsiveness of production servers running IIS and MS SQL Server 2005?
I'm currently using Pingdom and would like it to point to a URL which basically mimics a 'real world qu... |
SQL Server does not have a results cache like MySQL or Oracle, so I am a bit confused about your question. If you want the server to recompile the plan cache for a stored procedure, you can execute it WITH RECOMPILE. You can drop your buffer cache, but that would affect all queries as you know.
At my company, we test ... |
Best cache framework for Java [closed] |
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be imp... |
You can try to look at Terracotta framework
Or you can use distributed Ehcache
|
Setting the cache_store in an initializer |
I'm trying to use redis-store as my Rails 3 cache_store. I also have an initializer/app_config.rb which loads a yaml file for config settings. In my initializer/redis.rb I have:
MyApp::Application.config.cache_store = :redis_store, APP_CONFIG['redis']
However, this doesn't appear to work. If I do:
Rails.cache
in m... |
After some research, a probable explanation is that the initialize_cache initializer is run way before the rails/initializers are. So if it's not defined earlier in the execution chain then the cache store wont be set. You have to configure it earlier in the chain, like in application.rb or environments/production.rb
... |
Disable caching on a partial view in MVC 3 |
I have an issue with a partial View being cached when it shouldn't be. This partial View is used to display the Logon/Logoff on a page. It uses the simple code below to figure out which link to display
@if(Request.IsAuthenticated) {
<a href="@Url.Action("LogOff", "Account", new { area = "" })">Log Off</a>
}... |
What you are looking for is called Donut Caching. Here's a great article explaining what it is and how to make it work http://www.devtrends.co.uk/blog/donut-output-caching-in-asp.net-mvc-3
|
PHP: Measure size in kilobytes of a object/array? |
What's an appropriate way of measure
a PHP objects actual size in
bytes/kilobytes?
Reason for asking:
I am utilizing memcached for cache storage in my web application that will be used by non-technical customers. However, since memcached has a maximum size of 1mb , it would be great to have a function set up from t... |
Well, since Memcached doesn't store raw objects (it actually stores the serialiezd version), you can do this:
$serializedFoo = serialize($foo);
if (function_exists('mb_strlen')) {
$size = mb_strlen($serializedFoo, '8bit');
} else {
$size = strlen($serializedFoo);
}
|
AngularJS browser cache issues |
Good morning, I have a web application in production environement. The users are using it every day, when I publish an update and a user comes back to the web application he views the old version of the web application. He needs to refresh the browser to load the new version. How can I solve this problem? I cannot tel... |
A simple solution would be to add query strings representing timestamp or session id to your files.
For e.g., in our spring applications, we simply use :
<script src="js/angular/lib/app.js?r=<%= session.getId()%>"></script>
You can implement the same solution in your server specific implementation too.
|
cache a dataframe in pyspark |
I want to know more precisely about the use of the method cache for dataframe in pyspark
When I run df.cache() it returns a dataframe.
Therefore, if I do df2 = df.cache(), which dataframe is in cache ? Is it df, df2, or both ?
|
I found the source code DataFrame.cache
def cache(self):
"""Persists the :class:`DataFrame` with the default storage level (`MEMORY_AND_DISK`).
.. note:: The default storage level has changed to `MEMORY_AND_DISK` to match Scala in 2.0.
"""
self.is_cached = True
self._jdf.cache()
return self
T... |
Is the HttpContext.Current.Cache available to all sessions |
As per title. I want to be able to save some data in a cache object but this object must be available to all users/sessions and can expire.
What is the best method to achieve this in a asp.net web app?
|
HttpContext.Current is available to all pages, but not necessarily to all threads. If you try to use it inside a background thread, ThreadPool delegate, async call (using an ASP.NET Async page), etc., you'll end up with a NullReferenceException.
If you need to get access to the cache from library classes, i.e. classe... |
Nest.Js not accepting any changes |
I tried creating a new method inside AppController but it's not reflecting changes. I even tried to change the default getHello() method but it's outputting "Hello World!". How is this possible?
Insomnia
AppController
AppService
|
Update:
npm run build && npm run start fixed it
|
Do atomic operations become slower as more CPUs are added? |
x86 and other architectures provide special atomic instructions (lock, cmpxchg, etc.) that allow you to write 'lock free' data structures. But as more and more cores are added, it seems as though the work these instructions will actually have to do behind the scenes will grow (at least to maintain cache coherency?). I... |
You are right that topology constraints will, one way or another, increase latency of communication between cores, once the counts start going higher than a couple dozen. I don't really know what the intentions are of the x86 companies for dealing with that sort of scaling.
But locks are implemented in terms of atomi... |
Asp.net - Caching vs Static Variable for storing a Dictionary |
I am building a web-store with many departments and categories. They are stored in our database and accessed often.
We are using URL rewriting so almost every request within the store generates a lookup. We also need to iterate over the data frequently to generate menus for the main store and the department pages.
Th... |
The Application and Cache collections do not serialize the objects you pass into them, they store the actual reference. Retrieving an object from Cache will not be an expensive operation, no matter how large the object is. Always stick with the Cache objects unless you have a very good reason not to, its just good pra... |
Force Firefox to Reload Page on Back Button |
How do you make Firefox rerun javascript and reload the entire page when the user presses the back button? I was able to do this in all browsers except Firefox from the help of another SO question by adding this code:
history.navigationMode = 'compatible';
$("body").unload(function(){})
And also adding an iFrame... ... |
add this between your HEAD tags
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
|
Is 5MB the de facto limit for W3C Web Storage? |
I am looking into using browser sessionStorage for a web application, and was trying to find current information on size limitations. It appears most desktop browsers have imposed a 5MB limit. However, I am not finding many recent articles nor information on the mobile browsers.
The Disk space of the W3C Web Storage... |
Assuming that the smallest limit for html5 web storage is 5mb, it would be sensible to go with that answer given what information you have presented, and has been presented about W3C web storage. Do beware that everything is in flux, but I don't think this limit will change drastically.
|
Rails: cache.fetch vs cache.read/write |
is there any performance difference between
Rails.cache.fetch("key") { Model.all }
and
models = Rails.cache.read("key")
if models.nil?
models = Model.all
Rails.cache.write("key", models)
end
If I must guess, i would say the upper one is just a shorthand for the other one.
|
25
If you check the source code, you'll notice that fetch does nothing more than call read and write.
Since it does some other operations (like checking if a block has been given, etc.) one could say that fetch is heavier, but I think it's totally negligible.
Share
... |
When are files from NSCachesDirectory removed? |
In what circumstances would files in the iOS NSCachesDirectory get removed? Obviously, delete and reinstall an application. What about application upgrade? What about low disk space conditions? Anything else?
|
11
Our experience is that this folder gets cleared on app updates. It would be nice to know when exactly this folder is a candidate for being cleared. The docs describe this folder as
location of discardable cache files (Library/Caches)
The NSDocumentDirectory will not ... |
Rails 4 : What is cached when using config.cache_classes = true |
I was just wondering and didn't find explicit response on what in the model class (ActiveRecord) is cached when setting config.cache_classes to true ?
Could someone tell me or point me to the doc I didn't found ?
Thanks
|
It determines whether or not your application classes are reloaded on each request. If it's true, you have to restart your server for code changes to take effect (i.e. you set it to true in production, false in development.)
Documentation is here.
|
How do I completely disable caching in Cakephp? |
So I opened the cache floodgates in my Cakephp app and now I want to close them...
I've done pretty much everything I can: delete all files in the tmp folder (but not the folders), turned 'Cache.disable' on in the core.php file in my app, have tried clearing the cache from within some controllers with clearCache() and... |
13
To rule out browser caching as the root cause, you might try adding the following lines:
header('Cache-Control: no-store, private, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0, max-stale = 0', fal... |
In-memory cache VS. centralized cache in a distributed system |
We're currently looking for the most suitable solution for accessing critical data on a distributed system, and we're considering whether to use in memory caching, versus a centralized cache.
Some information about the data we wish to store/access:
Very small data size
Data is very cold; meaning it barely changes, an... |
I don't find any problem in going for a centralized cache using Redis.
Anyway you are going to have a cluster setup so if a master fails slave will take up the position.
If cache is flushed for some reason then you have to build the cache, in the mean time requests will get data from the primary source (DB)
You can... |
Caching attribute for method? |
Maybe this is dreaming, but is it possible to create an attribute that caches the output of a function (say, in HttpRuntime.Cache) and returns the value from the cache instead of actually executing the function when the parameters to the function are the same?
When I say function, I'm talking about any function, wheth... |
14
Your best bet is Postsharp. I have no idea if they have what you need, but that's certainly worth checking. By the way, make sure to publish the answer here if you find one.
EDIT: also, googling "postsharp caching" gives some links, like this one: Caching with C#, AOP an... |
ConcurrentHashMap put vs putIfAbsent |
Java Docs says that, putIfAbsent is equivalent to
if (!map.containsKey(key))
return map.put(key, value);
else
return map.get(key);
So if the key exists in the map, it doesn't update its value. Is this correct?
What if i want to update a keys value based on some criteria? Say expiration time etc.
... |
So it doesnt update a key's value. is this correct?
That is correct. It will return the current value that was already in the Map.
would this be a better impl for adding and updating cache?
A couple things would make your implementation better.
1. You shouldn't use putIfAbsent to test if it exists, you should onl... |
How to cache package manager downloads for docker builds? |
If I run composer install from my host, I hit my local composer cache:
- Installing deft/iso3166-utility (1.0.0)
Loading from cache
Yet when building a container having in its Dockerfile:
RUN composer install -n -o --no-dev
I download all the things, e.g.:
- Installing deft/iso3166-utility (1.0.0)
Downlo... |
9
Use the experimental feature : Docker buildkit (Supported Since docker 18.09, docker-compose 1.25.4)
In your dockerfile
# syntax=docker/dockerfile:experimental
FROM ....
# ......
RUN --mount=type=cache,target=/var/composer composer install -n -o --no-dev
Now before bui... |
Caching compiled regex objects in Python? |
Each time a python file is imported that contains a large quantity of static regular expressions, cpu cycles are spent compiling the strings into their representative state machines in memory.
a = re.compile("a.*b")
b = re.compile("c.*d")
...
Question: Is it possible to store these regular expressions in a cache on d... |
Is it possible to store these regular expressions in a cache on disk in a pre-compiled manner to avoid having to execute the regex compilations on each import?
Not easily. You'd have to write a custom serializer that hooks into the C sre implementation of the Python regex engine. Any performance benefits would be va... |
Dynamically Trigger HTML5 Cache Manifest file? |
I am using the new cache manifest functionality from HTML5 to cache my web app so it will work offline. The content is cached automatically when the page is loaded with the following html element:
<html lang="en" manifest="offline.manifest">
This works fine. However, I want to give my users the option of whether they... |
After many weeks spent with offline caching, the answer is no, you either cache or don't cache, setting the cache attribute on the client side has no effect.
You could consider offering an alternate url for the caching version, be aware that the page is also implicitly cached as a "master entry".
I am at a loss to und... |
Google App Engine - Caching generated HTML |
I have written a Google App Engine application that programatically generates a bunch of HTML code that is really the same output for each user who logs into my system, and I know that this is going to be in-efficient when the code goes into production. So, I am trying to figure out the best way to cache the generated... |
In order of speed:
memcache
cached HTML in data store
full page generation
Your caching solution should take this into account. Essentially, I would probably recommend using memcache anyways. It will be faster than accessing the data store in most cases and when you're generating a large block of HTML, one of the ... |
How to persist objects between requests in PHP |
I've been using rails, merb, django and asp.net mvc applications in the past. What they have common (that is relevant to the question) is that they have code that sets up the framework. This usually means creating objects and state that is persisted until the web server is recycled (like setting up routing, or checkin... |
Not sure if APC is the only solution but APC does take care of all your issues.
First, your script will be compiled once with APC and the bytecode is stored in memory.
If you have something taking long time to setup, you can also cache it in APC as user data. For example, I do this all the time,
$table = @... |
my ideal cache using guava |
Off and on for the past few weeks I've been trying to find my ideal cache implementation using guava's MapMaker. See my previous two questions here and here to follow my thought process.
Taking what I've learned, my next attempt is going to ditch soft values in favor of maximumSize and expireAfterAccess:
ConcurrentMap... |
Whether two maps is efficient depends entirely on how expensive getFromDatabase() is, and how big your objects are. It does not seem out of all reasonable boundaries to do something like this.
As for the implementation, It looks like you can probably layer your maps in a slightly different way to get the behavior you... |
Clear UIWebView cache when use local image file |
I use a UIWebView to load a local html, and there is a PNG file inside the html created by Objc.
After the PNG file has been modified, I reload the html in UIWebView, but the image doesn't change. However, if I quit the app and reopen it, the image file will be changed to the new one.
I have checked the PNG file in Do... |
You can try this, in your AppDelegate.m
+(void)initialize {
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
}
|
Why (and how) ASP.NET Cache gets stored in Unmanaged Memory? |
OK, all you ASP.NET Experts: I have used reflector to look into ASP.NET Cache implementation (which sits on HttpRuntime.Cache and HttpContext.Current.Cache) uses a Hashtable internally to keep the cache.
However, the data gets stored in unmanaged memory. This is very strange since I could not see anywhere data getting... |
The # Bytes in all Heaps is only updated when the garbage collection is executed, while the Private Bytes is available at much faster update rate. (I'm not sure where that number comes from, internally, and how often it's updated.)
The amount of Private Bytes increases just after 17:42:45. This amount does seem to mat... |
Comparison of memcache, redis and ehcache as distributed caching framework [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 ... |
A small feature comparison is here: http://toddrobinson.com/appfabric/appfabric-cache-feature-comparisons/
UPDATE 25.02.2016
Dead link fixed thanks to WebArchive.org: http://web.archive.org/web/20140205010302/http://toddrobinson.com/appfabric/appfabric-cache-feature-comparisons/
|
Django Cache cache.set Not storing data |
When I run python manage.py shell and then:
from django.core.cache import cache
cache.set("stack","overflow",3000)
print cache.get("stack")
(output: ) None
I tried restarting memcache, and here is what's in my settings:
CACHES = {
'default' : {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedC... |
3
Make sure it's using the correct cache. Try from django.core.cache import caches, and then see the contents of caches.all(). It should just have one instance of django.core.cache.backends.memcached.MemcachedCache.
If it is, try accessing that directly, e.g.
from django.... |
How do I empty Drupal Cache (without Devel) |
How do I empty the Drupal caches:
without the Devel module
without running some PHP Statement in a new node etc.
without going into the database itself
Effectively, how do you instruct an end user to clear his caches?
|
When you are logged as an admin (obviously, not every user of the site has to power to clear the cache), there should be a page in "Administer > Site Configuration > Performance".
And, at the bottom of the page, there should be a button (something like "Clear cached data") to clear the cache
As far as I remember, ther... |
How can I test if my redis cache is working? |
I've installed django-redis-cache and redis-py. I've followed the caching docs for Django. As far as I know, the settings below are all that I need. But how do I tell if it's working properly??
settings.py
CACHES = {
'default': {
'BACKEND': 'redis_cache.RedisCache',
'LOCATION': '<ho... |
Didn't work with Django yet, but here's my default approach for checking if some component actually writes to redis during development:
First, I flush all keys stored in redis in order to remove old cache entries (never do this in production as this removes all data from redis):
> redis-cli FLUSHALL
Then activate cac... |
Android ViewPager: Update off-screen but cached fragments in ViewPager |
I have a ViewPager which contains several TextViews inside its fragment which they have different font sizes.
In addition, I got buttons for increase/decreasing font size which calculate font size of each textView by adding its default size plus a value called STEP (which changes by inc/dec font size button).
My prob... |
In order to have a list of cached items by ViewPager I changed my Custom Adapter which an extension FragmentStatePagerAdapter:
Add a HashMap<Integer, FragmentDipsplayPageContent> cachedFragmentHashMap to my adapter
Update getItem() method like this
public Fragment getItem(int index) {
Fragment fragment = ... |
Chrome - why is it sending if-modified-since requests? |
I have a page with lots of small images (icons). When used with chrome, each time the page is reloaded, chrome requests each icon from the server with if-modified-since header.
All icons are served with expires and max-age headers. Firefox loads images from its cache.
Why is chrome doing that and how can I prevent it?... |
14
Have you checked the request headers?
"‘Cache-Control’ is always set to ‘max-age=0′, no matter if you press enter, f5 or ctrl+f5. Except if you start Chrome and enter the url and press enter."
http://techblog.tilllate.com/2008/11/14/clientside-cache-control/
Shar... |
Get Asp.net/iis to set Cache-control:max-age for static files |
We have a Webforms project with url routing. I have defined exception routes for images and css-files as
routes.Add("IgnoreImages", new Route("img/{*pathInfo}", new StopRoutingHandler()));
routes.Add("IgnoreCss", new Route("css/{*pathInfo}", new StopRoutingHandler()));
so static files should be served by IIS directly... |
The solution is using the system.webserver section in the web.config file to configure server caching (and compression). Here is a starting point: http://www.iis.net/ConfigReference/system.webServer/staticContent/clientCache
Example:
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheCon... |
How does the ASP.NET Cache work? |
I am interested in using the ASP.NET Cache to decrease load times. How do I go about this? Where do I start? And how exactly does caching work?
|
As applications grow it is quite normal to leverage caching as a way to gain scalability and keep consistent server response times. Caching works by storing data in memory to drastically decrease access times. To get started I would look at ASP.NET caching.
There are 3 types of general Caching techniques in ASP.NET w... |
Does Powershell have a cache that needs to be cleared? |
This morning, I copied a directory from my local, networked drive to temp folder for testing. This error appeared.
Get-Content : Cannot find path 'C:\users\xxxxx\desktop\cgc\Automatic_Post-Call_Survey_-_BC,_CC.txt' because it does no
t exist.
At C:\users\xxxxx\desktop\cgc\testcountexcl1.ps1:55 char:12
+ Get-Content <... |
Variables are stored in the session, so if you close your powershell console and open a new one, all custom variables will be gone. If you want to see what variables exists, use Get-Variable . To delete a specific variable(to make sure it's gone), you could use:
Remove-Variable varname.
As for you question. A variable... |
How to cache dynamic PHP page |
How to cache PHP page which has mysql query. Any example will be great and helpful.
|
18
I am using phpFastCache ( for shared hosting, if you don't want to touch php.ini and root to setup memcached). Check out the Example Menu. They have full detail example, and very easy.
First you set with phpFastCache::set and then get with phpFastCache::get - DONE!
Exa... |
Shared hit cache in postgreSQL |
I'm experimenting with the EXPLAIN command and trying to find out what the shared hit is.
Seq Scan on foo (cost=0.00..18334.00 rows=1000000 width=37) (actual time=0.030..90.500 rows=1000000 loops=1)
Buffers: shared hit=512 read=7822
Total runtime: 116.080 ms
I've noticed that the more shared hit number we have the... |
shared hit essentially means the value has already been cached in the main memory of the computer and it was not necessary to read this from the hard disk.
Accessing the main memory (RAM) is much faster than reading values from the hard disk. And that's why the query is faster the more share hits it has.
Immediately... |
Performance of jQuery selectors vs local variables |
Is it recommended that, when I need to access the result of a jQuery selector more than once in the scope of a function, that I run the selector once and assign it to a local variable?
Forgive my trite example here, but i think it illustrates the question.
So, will this code perform faster:
var execute = function(){
... |
Reusing the selector reference, your first case, is definitely faster. Here's a test I made as proof:
http://jsperf.com/caching-jquery-selectors
The latter case, redefining your selectors, is reported as ~35% slower.
|
Loading Cache when Offline in Android Webview |
I have an application which loads urls from a website. Now I want the application to use the cache when offline. But I just get the failure page which says that im not connected to the website. At first I set the Cachemode to Load_Normal but this doesn't help. Next I tried a realy "silly" approach using the Connectiv... |
OK. The code is fine above. The permission needed to be added are:
.INTERNET
.ACCESS_NETWORK_STATE
.ACCESS_WIFI_STATE
|
How to avoid running Snakemake rule after input or intermediary output file was updated |
Even if the output files of a Snakemake build already exist, Snakemake wants to rerun my entire pipeline only because I have modified one of the first input or intermediary output files.
I figured this out by doing a Snakemake dry run with -n which gave the following report for updated input file:
Reason: Updated inpu... |
17
You can use the option --touch to mark them up to date:
--touch, -t
Touch output files (mark them up to date without
really changing them) instead of running their
commands. This is used to pretend that the rules wer... |
Default Cache Manager with Spring Boot using @EnableCaching |
I have implemented caching in my SpringBootApplication as shown below
@SpringBootApplication
@EnableCaching
public class SampleApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Sa... |
The Spring Boot starter provides a simple cache provider which stores values in an instance of ConcurrentHashMap. This is the simplest possible thread-safe implementation of the caching mechanism.
If the @EnableCaching annotation is present in your app, Spring Boot checks dependencies available on your class path and ... |
Caching in a console application |
I need to cache a generic list so I dont have to query the databse multiple times. In a web application I would just add it to the httpcontext.current.cache . What is the proper way to cache objects in console applications?
|
Keep it as instance member of the containing class. In web app you can't do this since page class's object is recreated on every request.
However .NET 4.0 also has MemoryCache class for this purpose.
|
Chrome is not clearing cache |
I am working on a new site and whenever I change CSS settings chrome will not accept those changes unless I close out of chrome completely with Task manager and relaunch it. I have a tried quite a few things. Below is a list of things I've tried:
Versioning the CSS file (I am using a PHP date stamp at the end of the ... |
Development server was running various caching tools though they should have been turned off. After disabling them chrome started to work better and most of the time CTRL+F5 did the trick.
|
local cache for a github repository? |
We use github to manage a great deal of our software environment, and I would wager that like many other orgs the overwhelming majority of traffic to/from that repo comes from our office. With that in mind, is there a way to build a local cache of a given github repository, but still have the protection of the cloud ... |
You should check out the git-cache-http-server project. I think it partly implements what you need (and is similar to the idea from @larsks post).
It is a NodeJS piece of software that runs an HTTP server to provide you access to locally cached git repositories. The server automatically does fetch upstream changes w... |
Debugging when using require.js cache |
Using require.js I noticed that often the dependencies are cached by the browser and don't get updated even if I force the page to completely reload (command+shift+R).
In order to have always the updated file, I made require.js ask for the files adding '?datestamp' after the url. The only problem with this approach is... |
Actually there are some things you can do:
Either you disable your browser caching completely to test it. An easy way in e.g. Chrome is to open a Incognito Window (CTRL + SHIFT + N) similar to the Private Browsing mode in Firefox. However the more ideal solution for you should be listed here: Disabling Chrome cache fo... |
Is there any way to cache all files of defined folder/path in service worker? |
In service worker, I can define array of resource those are being cached during service worker get started mentioned below:
self.addEventListener('install', event => {
event.waitUntil(caches.open('static-${version}')
.then(cache => cache.addAll([
'/styles.css',
'/script.js'
... |
Runtime caching using Workbox sw.
service-worker.js:
importScripts('https://unpkg.com/[email protected]/build/importScripts/workbox-sw.dev.v0.0.2.js');
importScripts('https://unpkg.com/[email protected]/build/importScripts/workbox-runtime-caching.prod.v1.3.0.js');
importScripts('https://unpkg.com/[email protected]/bui... |
Can I iterate over the .NET4 MemoryCache? |
I'm using the cache provided by System.Runtime.Caching.MemoryCache.
I'd like to enumerate over the cache's items so that I can invalidate (evict then reload) items as such
foreach (var item in MemoryCache.Default) { item.invalidate() }
But the official docs found here state:
!Important: Retrieving an enumerator for ... |
Suggestions made so far have been great, but my need is still as stated: to iterate over the cache's items. It seems like such a simple task, and I expect that the cache internally has some sort of list structure anyway. The docs and the feature set for MemoryCache are wanting.
So as discussed above, I've added a list... |
Reactive Caching of HTTP Service |
I am using RsJS 5 (5.0.1) to cache in Angular 2. It works well.
The meat of the caching function is:
const observable = Observable.defer(
() => actualFn().do(() => this.console.log('CACHE MISS', cacheKey))
)
.publishReplay(1, this.RECACHE_INTERVAL)
.refCount().take(1)
.do(() => this.console.log('CACHE HIT... |
3
+125
Almost any complicated logic quickly goes out of control if you use plain rxjs. I would rather implement custom cache operator from scratch, you can use this gist as an example.
Share
Improve this answer
... |
Saving webpage in cache using webview in android |
I am working on an application where I load few websites in webview now I want to save webpages so after sometime even if there is not internet user will able to see those pages. But I am confused on how to save whole webpage in cache or any other medium. The main thing is we need to show pages back even if there is n... |
The easiest way is save webpages in cache directory or any other(Internal or external storage)
You can get the data of web page using HttpClient.execute() or HttpClient.get() now store that data in .html file also you have to download images or other contents which are bind to that page, Now in your application you ha... |
How To Disable AFNetworking Cache |
Is it possible to disable all the cache features from AFNetworking?
I am building my own custom cache system and don't want this to take up disk space too.
Thanks,
Ashley
|
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 r... |
Optionally testing caching in Rails 3 functional tests |
Generally, I want my functional tests to not perform action caching. Rails seems to be on my side, defaulting to config.action_controller.perform_caching = false in environment/test.rb. This leads to normal functional tests not testing the caching.
So how do I test caching in Rails 3.
The solutions proposed in this th... |
You're liable to end up with tests stomping on each other. You should wrap this up with ensure and reset it to old values appropriately. An example:
module ActionController::Testing::Caching
def with_caching(on = true)
caching = ActionController::Base.perform_caching
ActionController::Base.perform_caching = ... |
How to delete cache-folder of app? |
I read through the Android documentation of the cache (see Data Storage Documentation) but I didn't got how I can clean the whole folder.
So how can I delete the cache-folder of my app? It's in this path:
/Android/data/de.stepforward/cache/
|
Put this code in onDestroy() to clear app cache:
void onDestroy() { super.onDestroy();
try {
trimCache(this);
// Toast.makeText(this,"onDestroy " ,Toast.LENGTH_LONG).show();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static v... |
Asking browsers to cache our images (ASP.NET/IIS) |
I just ran Google's Page Speed application against our site and one of the recommendations was to Leverage browser caching. Expanding this revealed the following:
The following cacheable resources have
a short freshness lifetime:
Specify an expiration at least one week in
the future for the following resources... |
I found the answer to my question elsewhere on this site. Woot! (Not sure why it didn't appear when I first posted this, but never mind, I got there in the end.)
For those interested, the answer was this (as posted by Gabriel McAdams):
You do that in IIS. If you are using IIS 7, you can add the header in your web.con... |
Fastest way to gather facts to fact cache |
I am trying to make Ansible work with --limit and to do that I need facts about other hosts, which I am caching with fact_caching. What command should I run so that it simply gathers all the facts on all the hosts and caches them, without running any tasks? Something like the setup module would be perfect if it cached... |
Here is how I'd solve the problem:
1.- Enable facts gathering on your playbook (site.yml):
gather_facts: yes
2.- Enable facts caching on ansible.cfg:
2.1.- Option 1 - Use this if you have the time to install redis:
[defaults]
gathering = smart
fact_caching = redis
# two hours timeout
fact_caching_timeout = 7200
2.2... |
HTTP cache headers with .htaccess |
I am trying to configure my .htaccess file to set the cache time. Tryied every possible configuration but nothing works!
This is what is written in my HTML:
<meta http-equiv="Cache-Control" content="max-age=2592000, public" />
<!--
<meta http-equiv="expires" content="mon, 24 sep 2012 14:30:00 GMT">
-->
... |
51
I advise you to use headers mod. You can activate it (if disabled) with this command :
a2enmod headers
Here is a simple code example that works:
<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=6... |
Mac : There was an error while executing `VBoxManage`, a CLI used by Vagrant |
I am working with aerospike and installing it using vagrant virtual box.
After installation, when i am trying to start the virtual machine, it is giving the following error:
. There was an error while executing VBoxManage, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Comm... |
Proceeding with the following steps helped me out:
restart the virtual box using:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
Stop vagrant as follows:
vagrant halt
start vagrant as follows:
vagrant up
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.