Prompt stringlengths 14 160 | Instruction stringlengths 18 2k | Response stringlengths 8 2k |
|---|---|---|
Cache Invalidation — Is there a General Solution? |
"There are only two hard problems in Computer Science: cache invalidation and naming things."
Phil Karlton
Is there a general solution or method to invalidating a cache; to know when an entry is stale, so you are guaranteed to always get fresh data?
For example, consider a function getData() that gets data from a fi... |
What you are talking about is lifetime dependency chaining, that one thing is dependent on another which can be modified outside of it's control.
If you have an idempotent function from a, b to c where, if a and b are the same then c is the same but the cost of checking b is high then you either:
accept that you some... |
Stop caching for PHP 5.5.3 in MAMP |
Installed MAMP on a new Macbook with PHP 5.5.3.
Reload and refresh do nothing. Still nothing. Google around for a few minutes trying to find out what is wrong, come back and refresh. It works. What the heck?
I went into php.ini and disabled all the new OPcache and set the default cache time to 0. Added headers to the... |
Disable OPCache
MAMP now turns on OPCache by default, you can disable it by editing your php.ini file. Make sure you edit the correct php.ini.
I was running into the same problem myself. MAMP with PHP version 5.5.3 runs OPcache by default, but you can't turn it off in the GUI like you can with the older PHP version 5.... |
NodeJS/express: Cache and 304 status code |
When I reload a website made with express, I get a blank page with Safari (not with Chrome) because the NodeJS server sends me a 304 status code.
How to solve this?
Of course, this could also be just a problem of Safari, but actually it works on all other websites fine, so it has to be a problem on my NodeJS server, t... |
142
Easiest solution:
app.disable('etag');
Alternate solution here if you want more control:
http://vlasenko.org/2011/10/12/expressconnect-static-set-last-modified-to-now-to-avoid-304-not-modified/
Share
Improve this answer
Follow
... |
How to clear MemoryCache? |
I have created a cache using the MemoryCache class. I add some items to it but when I need to reload the cache I want to clear it first. What is the quickest way to do this? Should I loop through all the items and remove them one at a time or is there a better way?
|
Dispose the existing MemoryCache and create a new MemoryCache object.
|
How to call cURL without using server-side cache? |
Is there a way to tell cURL command not to use server's side cache?
e.g; I have this curl command:
curl -v www.example.com
How can I ask curl to send a fresh request to not use the cache?
Note: I am looking for an executable command in the terminal.
|
I know this is an older question, but I wanted to post an answer for users with the same question:
curl -H 'Cache-Control: no-cache' http://www.example.com
This curl command servers in its header request to return non-cached data from the web server.
|
Looking for simple Java in-memory cache [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... |
Since this question was originally asked, Google's Guava library now includes a powerful and flexible cache. I would recommend using this.
|
Clear file cache to repeat performance testing |
What tools or techniques can I use to remove cached file contents to prevent my performance results from being skewed? I believe I need to either completely clear, or selectively remove cached information about file and directory contents.
The application that I'm developing is a specialised compression utility, and i... |
Use SysInternal's RAMMap app.
The Empty / Empty Standby List menu option will clear the Windows file cache.
|
Why doesn't the JVM cache JIT compiled code? |
The canonical JVM implementation from Sun applies some pretty sophisticated optimization to bytecode to obtain near-native execution speeds after the code has been run a few times.
The question is, why isn't this compiled code cached to disk for use during subsequent uses of the same function/class?
As it stands, eve... |
Without resorting to cut'n'paste of the link that @MYYN posted, I suspect this is because the optimisations that the JVM performs are not static, but rather dynamic, based on the data patterns as well as code patterns. It's likely that these data patterns will change during the application's lifetime, rendering the ca... |
Clear cache in GitHub Actions |
I am working on an R package and using GitHub Action (GHA) as a Continuous Integration (CI) provider. I cache R packages (dependencies) by using actions/cache. And now I want to clear all cache. How can I do that?
A part of GHA Workflow I use:
on: push
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix... |
Update (July 11, 2023)
As already described in VonC's answer, the GitHub CLI now has a dedicated cache top-level command:
List of caches for the current repository:
$ gh cache list
Delete a cache for the current repository by cache ID:
$ gh cache delete <CACHE_ID>
Update (October 20, 2022)
You can now manage cac... |
Amazon S3 and Cloudfront cache, how to clear cache or synchronize their cache |
I have a cron job that runs every 10 minutes and updates the content-type and x-amz-meta. But since yesterday it seems like after the cron job run, Amazon is not picking up the changes made (refreshing his cache).
I even went and made the changes manually but no change...
When a video is uploaded it has a application/... |
86
Use Invalidations to clear the cache, you can put the path to the files you want to clear, or simply use wild cards to clear everything.
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html#invalidating-objects-api
This can also be done u... |
How does Lru_cache (from functools) Work? |
Especially when using recursive code there are massive improvements with lru_cache. I do understand that a cache is a space that stores data that has to be served fast and saves the computer from recomputing.
How does the Python lru_cache from functools work internally?
I'm Looking for a specific answer, does it use d... |
The functools source code is available here: https://github.com/python/cpython/blob/master/Lib/functools.py
lru_cache uses the _lru_cache_wrapper decorator (python decorator with arguments pattern) which has a cache dictionary in context in which it saves the return value of the function called (every decorated functi... |
See and clear Postgres caches/buffers? |
Sometimes I run a Postgres query and it takes 30 seconds. Then, I immediately run the same query and it takes 2 seconds. It appears that Postgres has some sort of caching. Can I somehow see what that cache is holding? Can I force all caches to be cleared for tuning purposes?
I'm basically looking for a Postgres versio... |
You can see what's in the PostgreSQL buffer cache using the pg_buffercache module. I've done a presentation called "Inside the PostgreSQL Buffer Cache" that explains what you're seeing, and I show some more complicated queries to help interpret that information that go along with that.
It's also possible to look at t... |
Max value for cache control header in HTTP |
I'm using Amazon S3 to serve static assets for my website. I want to have browsers cache these assets for as long as possible. What meta-data headers should I include with my assets
Cache-Control: max-age=???
|
Generally one year is advised as a standard max value. See RFC 2616:
To mark a response as "never expires," an origin server sends an
Expires date approximately one year from the time the response is
sent. HTTP/1.1 servers SHOULD NOT send Expires dates more than one
year in the future.
Although that applies to... |
Prevent safari loading from cache when back button is clicked |
Got an issue with safari loading old youtube videos when back button is clicked. I have tried adding onunload="" (mentioned here Preventing cache on back-button in Safari 5) to the body tag but it doesn't work in this case.
Is there any way to prevent safari loading from cache on a certain page?
|
Your problem is caused by back-forward cache. It is supposed to save complete state of page when user navigates away. When user navigates back with back button page can be loaded from cache very quickly. This is different from normal cache which only caches HTML code.
When page is loaded for bfcache onload event wont ... |
Visual Studio retrieving an incorrect path to a project from somewhere |
Visual Studio (and possibly TFS) has somehow (I think perhaps during a source control merge) become confused about the path of a project within my solution.
It thinks it is here (example paths for simplicity):
C:\My Projects\ExampleSolution\ExampleProjectWrong\ExampleProjectCorrect.csproj
whereas actually, the projec... |
Go to Manage Workspaces (either through the File/Source Control menu or the workspace drop down in Source Control Explorer)
select edit for your workspace.
You should see, under working folders, a mapping for the source
control directory to the old/wrong project directory.
Select it and click remove.
Close VS and del... |
IIS7 Cache-Control |
I'm trying to do something which I thought would be fairly simple. Get IIS 7 to tell clients they can cache all images on my site for a certain amount of time, let's say 24 hours.
I have tried the step on http://www.galcho.com/Blog/post/2008/02/27/IIS7-How-to-set-cache-control-for-static-content.aspx but to no avai... |
If you want to set the Cache-Control header, there's nothing in the IIS7 UI to do this, sadly.
You can however drop this web.config in the root of the folder or site where you want to set it:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControl... |
Lightweight Java Object cache API [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... |
EHCache is very nice. You can create an in memory cache. Check out their code samples for an example of creating an in memory cache. You can specify a max size, and a time to live.
EHCache does offer some advanced features, but if your not interested in using them - don't. But it's nice to know they are there if yo... |
Remove image from cache in Glide library |
I am using Glide in one of my projects to show images from files.
Below is my code of how I am showing the image:
Glide.with(DemoActivity.this)
.load(Uri.parse("file://" + imagePath))
.into(mImage);
The image at this location(imagePath) keeps on changing. By default Glide cache the image it shows in the Ima... |
This is how I solved this problem.
Method 1: When the URL changes whenever the image changes
Glide.with(DemoActivity.this)
.load(Uri.parse("file://" + imagePath))
.diskCacheStrategy(DiskCacheStrategy.NONE)
.skipMemoryCache(true)
.into(mImage);
diskCacheStrategy() can be used to handle the disk cache a... |
In PHP how can you clear a WSDL cache? |
In through php_info() where the WSDL cache is held (/tmp), but I don't necessarily know if it is safe to delete all files starting with WSDL.
Yes, I should be able to just delete everything from /tmp, but I don't know what else this could effect if I delete any all WSDL files.
|
You can safely delete the WSDL cache files. If you wish to prevent future caching, use:
ini_set("soap.wsdl_cache_enabled", 0);
or dynamically:
$client = new SoapClient('http://somewhere.com/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE) );
|
Python functools lru_cache with instance methods: release object |
How can I use functools.lru_cache inside classes without leaking memory?
In the following minimal example the foo instance won't be released although going out of scope and having no referrer (other than the lru_cache).
from functools import lru_cache
class BigClass:
pass
class Foo:
def __init__(self):
... |
This is not the cleanest solution, but it's entirely transparent to the programmer:
import functools
import weakref
def memoized_method(*lru_args, **lru_kwargs):
def decorator(func):
@functools.wraps(func)
def wrapped_func(self, *args, **kwargs):
# We're storing the wrapped method insi... |
Line size of L1 and L2 caches |
From a previous question on this forum, I learned that in most of the memory systems, L1 cache is a subset of the L2 cache means any entry removed from L2 is also removed from L1.
So now my question is how do I determine a corresponding entry in L1 cache for an entry in the L2 cache. The only information stored in th... |
In core i7 the line sizes in L1 , L2 and L3 are the same: that is 64 Bytes.
I guess this simplifies maintaining the inclusive property, and coherence.
See page 10 of: https://www.aristeia.com/TalkNotes/ACCU2011_CPUCaches.pdf
|
How do I tell Spring cache not to cache null value in @Cacheable annotation |
Is there a way to specify that if the method returns null value, then don't cache the result in @Cacheable annotation for a method like this?
@Cacheable(value="defaultCache", key="#pk")
public Person findPerson(int pk) {
return getSession.getPerson(pk);
}
Update:
here is the JIRA issue submitted regarding caching ... |
Hooray, as of Spring 3.2 the framework allows for this using Spring SpEL and unless. Note from the java doc for Cacheable element unless:
Spring Expression Language (SpEL) expression used to veto method caching. Veto caching the result if the condition evaluates to true.
Unlike condition(), this expression is evaluat... |
if-modified-since vs if-none-match |
What could be the difference between if-modified-since and if-none-match? I have a feeling that if-none-match is used for files whereas if-modified-since is used for pages?
|
Regarding the differences between Last-Modified/If-Modified-Since and ETag/If-None-Match:
Both can be used interchangeably. However depending on the type of resource, and how it is generated on the server, one or the other question ("has this been modified since ...?" / "does this still match this ETag?") may be easie... |
System.Runtime.Caching.MemoryCache vs HttpRuntime.Cache - are there any differences? |
I'm wondering if there are any differences between MemoryCache and HttpRuntime.Cache, which one is preferred in ASP.NET MVC projects?
As far as I understand, both are thread safe, API is from first sight more or less the same, so is there any difference when to use which?
|
HttpRuntime.Cache gets the Cache for the current application.
The MemoryCache class is similar to the ASP.NET Cache class.
The MemoryCache class has many properties and methods for accessing the cache that will be familiar to you if you have used the ASP.NET Cache class.
The main difference between HttpRuntime.Cache a... |
What is TLB shootdown? |
What is a TLB shootdown in SMPs?
I am unable to find much information regarding this concept. Any good example would be very much appreciated.
|
A quick example:
You have some memory shared by all of the processors in your system.
One of your processors restricts access to a page of that shared memory.
Now, all of the processors have to flush their TLBs, so that the ones that were allowed to access that page can't do so any more.
The actions of one processor... |
What is StringIO in python used for in reality? |
What exactly is StringIO used for?
I have been looking around the internet for some examples. However, almost all of the examples are very abstract. And they just show "how" to use it. But none of them show "why" and "in which circumstances" one should/will use it?
p.s. not to be confused with this question on stackov... |
It's used when you have some API that only takes files, but you need to use a string. For example, to compress a string using the gzip module in Python 2:
import gzip
import StringIO
stringio = StringIO.StringIO()
gzip_file = gzip.GzipFile(fileobj=stringio, mode='w')
gzip_file.write('Hello World')
gzip_file.close()
... |
Is it possible to prevent an NSURLRequest from caching data or remove cached data following a request? |
On iPhone, I perform a HTTP request using NSURLRequest for a chunk of data. Object allocation spikes and I assign the data accordingly. When I finish with the data, I free it up accordingly - however instruments doesn't show any data to have been freed!
My theory is that by default HTTP requests are cached, however - ... |
Usually it's easier to create the request like this
NSURLRequest *request = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60.0];
Then create the connection
NSURLConnection *conn = [NSURLConnection connectionWithRequest:request
delegate:self];
and ... |
Firefox keeps form data on reload |
I have a big problem with the functionality in Firefox that keeps data that the user have filled in on reload F5. If i use Ctrl+F5 the forms are cleared and this is great. My problem is that not all my users know that this is what they have to do to force the input cleanup. Is there a way in the html or response heade... |
Just add autocomplete="off" to your inputs and you will solve the problem.
<input type="text" autocomplete="off">
jQuery to solve this on all inputs and textareas
$('input,textarea').attr('autocomplete', 'off');
|
What's default value of cache-control? |
My problem is: sometimes browser over-cached some resources even if i've already modified them. But After F5, everything is fine.
I studied this case whole afternoon. Now i completely understood the point of "Last-Modified" or "Cache-Control". And i know how to solve my issue (just .js?version or explicit max-age=xxxx... |
25
RFC 7234 details what browsers and proxies should do by default:
Although caching is an entirely OPTIONAL feature of HTTP, it can be
assumed that reusing a cached response is desirable and that such
reuse is the default behavior when no requirement or local
con... |
Disabling browser caching for all browsers from ASP.NET |
I'm after a definitive reference to what ASP.NET code is required to disabled browsers from caching the page. There are many ways to affect the HTTP headers and meta tags and I get the impression different settings are required to get different browsers to behave correctly. It would be really great to get a reference ... |
This is what we use in ASP.NET:
// Stop Caching in IE
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
// Stop Caching in Firefox
Response.Cache.SetNoStore();
It stops caching in Firefox and IE, but we haven't tried other browsers. The following response headers are added by these statements:
Cac... |
failed to open stream: HTTP wrapper does not support writeable connections |
I have uploaded my localhost files to my website but it is showing me this error:-
: [2] file_put_contents( ***WebsiteURL*** /cache/lang/ ***FileName*** .php)
[function.file-put-contents]: failed to open stream: HTTP wrapper does
not support writeable connections | LINE: 127 | FILE: /home/content/
***Folders\FileNam... |
Instead of doing file_put_contents(***WebSiteURL***...) you need to use the server path to /cache/lang/file.php (e.g. /home/content/site/folders/filename.php).
You cannot open a file over HTTP and expect it to be written. Instead you need to open it using the local path.
|
What is the difference between no-cache and no-store in Cache-control? |
I don't find get the practical difference between Cache-Control:no-store and Cache-Control:no-cache.
As far as I know, no-store means that no cache device is allowed to cache that response. In the other hand, no-cache means that no cache device is allowed to serve a cached response without validate it first with the s... |
But what is that check about?
Exactly checking Last-Modified or ETag. Client would ask server if it has new version of data using those headers and if the answer is no it will serve cached data.
Update
From RFC
no-cache
If the no-cache directive does not specify a field-name, then a cache MUST NOT use
the res... |
What is the difference between LRU and LFU |
What is the difference between LRU and LFU cache implementations?
I know that LRU can be implemented using LinkedHashMap.
But how to implement LFU cache?
|
Let's consider a constant stream of cache requests with a cache capacity of 3, see below:
A, B, C, A, A, A, A, A, A, A, A, A, A, A, B, C, D
If we just consider a Least Recently Used (LRU) cache with a HashMap + doubly linked list implementation with O(1) eviction time and O(1) load time, we would have the following ... |
Ruby on Rails: Clear a cached page |
I have a RoR application (ruby v1.8.7; rails v2.3.5) that is caching a page in the development environment. This wouldn't be so much of an issue, but the cached page's a elements are incorrect.
I haven't made any changes to the development.rb file and I haven't knowingly added any caching commands to the controllers.... |
This line in development.rb ensures that caching is not happening.
config.action_controller.perform_caching = false
You can clear the Rails cache with
Rails.cache.clear
That said - I am not convinced this is a caching issue. Are you making changes to the page and not seeing them reflected? You aren't pe... |
How does Docker know when to use the cache during a build and when not? |
I'm amazed at how good Docker's caching of layers works but I'm also wondering how it determines whether it may use a cached layer or not.
Let's take these build steps for example:
Step 4 : RUN npm install -g node-gyp
---> Using cache
---> 3fc59f47f6aa
Step 5 : WORKDIR /src
---> Using cache
---> 5c6956ba5856
Ste... |
The build cache process is explained fairly thoroughly in the Best practices for writing Dockerfiles: Leverage build cache section.
Starting with a parent image that is already in the cache, the next instruction is compared against all child images derived from that base image to see if one of them was built using t... |
Chrome WON'T clear cache... ctrl + F5 doesn't seem to work either |
I'm working on a web project but I have this really annoying issue with my browser, Google Chrome...
Every time I make changes on my website, my browser won't refresh and clear the cache. It works totally fine in my friend's Chrome browser, but not for me apparently.
As mentioned ctrl + F5 does not work for me. I trie... |
I have had a similar problem. What I find is that I need to open up the Chrome developer tools and then hit Ctrl + F5. Only then is the cache refreshed.
Update
Also, I would recommend that you select "Disable Cache" in the developers tools ("Network" tab).
|
htaccess - How to force the client's browser to clear the cache? |
For my site I have the following htaccess rules:
# BEGIN Gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>
# END Gzip
# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault ... |
You can force browsers to cache something, but
You can't force browsers to clear their cache.
Thus the only (AMAIK) way is to use a new URL for your resources. Something like versioning.
|
Why Integer class caching values in the range -128 to 127? |
Regarding my previous Question, Why do == comparisons with Integer.valueOf(String) give different results for 127 and 128? , we know that Integer class has a cache which stores values between -128 and 127.
Just wondering, why between -128 and 127?
Integer.valueOf() documentation stated that it "caching frequently req... |
Just wondering, why between -128 and 127?
A larger range of integers may be cached, but at least those between -128 and 127 must be cached because it is mandated by the Java Language Specification (emphasis mine):
If the value p being boxed is true, false, a byte, or a char in the range \u0000 to \u007f, or an int or... |
What can cause Chrome to give an net::ERR_FAILED on cached content against a server on localhost? |
I'm building a web server and trying to test things. The server is running on localhost:888, and the first time I load the web app, everything works. But if I try to reload the page, a bunch of XmlHttpRequest requests fail with net::ERR_FAILED. By putting breakpoints in the server code, I can verify that the reques... |
50
I run into similar problem. I have copied request as fetch in Network tab in devtools.
Then I have run it in browser dev console. There I could read description of the error about CORS. After setting cors on the api server, it worked.
You have to paste the fetch command ... |
Make @lru_cache ignore some of the function arguments |
How can I make @functools.lru_cache decorator ignore some of the function arguments with regard to caching key?
For example, I have a function that looks like this:
def find_object(db_handle, query):
# (omitted code)
return result
If I apply lru_cache decorator just like that, db_handle will be included in th... |
With cachetools you can write:
from cachetools import cached
from cachetools.keys import hashkey
from random import randint
@cached(cache={}, key=lambda db_handle, query: hashkey(query))
def find_object(db_handle, query):
print("processing {0}".format(query))
return query
queries = list(range(5))
queries.ex... |
Caching in asp.net-mvc |
I would like to cache my most database heavy actions in my asp.net-mvc site.
In my research I have found
donut caching on Phil's blog
Caching/compressing filters on Kazi's blog
Scott Hansleman's podcast about how they cached things in SO.
But I don't feel I get it yet.
I want to be able to cache my POST request dep... |
I like to cache in the model or data layer as well. This isolates everything to do with retrieving data from the controller/presentation. You can access the ASP.NET cache from System.Web.HttpContext.Current.Cache or use the Caching Application Block from the Enterprise Library. Create your key for the cached data f... |
Ideal HTTP cache control headers for different types of resources |
I want to find a minimal set of headers, that work with "all" caches and browsers (also when using HTTPS!)
On my web site, I'll have three kinds of resources:
(1) Forever cacheable (public / equal for all users)
Example: 0A470E87CC58EE133616F402B5DDFE1C.cache.html (auto generated by GWT)
These files are automaticall... |
I would probably use these settings:
Cache-Control: max-age=31556926 – Representations may be cached by any cache. The cached representation is to be considered fresh for 1 year:
To mark a response as "never expires," an origin server sends an
Expires date approximately one year from the time the response is
se... |
What is the best way to lock cache in asp.net? |
I know in certain circumstances, such as long running processes, it is important to lock ASP.NET cache in order to avoid subsequent requests by another user for that resource from executing the long process again instead of hitting the cache.
What is the best way in c# to implement cache locking in ASP.NET?
|
Here's the basic pattern:
Check the cache for the value, return if its available
If the value is not in the cache, then implement a lock
Inside the lock, check the cache again, you might have been blocked
Perform the value look up and cache it
Release the lock
In code, it looks like this:
private static object ThisL... |
Rails.cache.clear certain key names? |
Is it possible to somehow run Rails.cache.clear and only clear keys with a certain name/string?
I don't want to clear the entire cache...just keys with the string blog/post in the name (ie. blog/post/1, blog/post/2).
I'm using dalli with memcached for my cache and running Rails 3.0.6.
|
To answer my own question...it seems that given I'm using memcached, I actually can't use delete_if or delete_matched because memcached does not support enumerating or querying keys by pattern (1).
|
How does the chrome browser determine memory cache and disk cache? |
I knew that Google Chrome supports from memory cache and from disk cache when I request resources. However, I didn't see from memory cache before.
How does chrome determine which resources should be cached in memory?
|
1
The Chrome browser mostly looks at the cache-control header from the response header; if this header has immutable it will store the response to disk. Memory cache is loaded from the RAM so that which is much faster than disk cache & Memory cache is not persisted while cl... |
How to set cache: false in jQuery.get call |
jQuery.get() is a shorthand for jQuery.ajax() with a get call. But when I set cache:false in the data of the .get() call, what is sent to the server is a parameter called cache with a value of false. While my intention is to send a timestamp with the data to the server to prevent caching which is what happens if I us... |
To me, the correct way of doing it would be the ones listed. Either ajax or ajaxSetup. If you really want to use get and not use ajaxSetup then you could create your own parameter and give it the value of the the current date/time.
I would however question your motives in not using one of the other methods.
|
Fighting client-side caching in Django |
I'm using the render_to_response shortcut and don't want to craft a specific Response object to add additional headers to prevent client-side caching.
I'd like to have a response that contains:
Pragma: no-cache
Cache-control : no-cache
Cache-control: must-revalidate
And all the other nifty ways that browsers will h... |
You can achieve this using the cache_control decorator. Example from the documentation:
from django.views.decorators.cache import never_cache
@never_cache
def myview(request):
# ...
|
Easy, simple to use LRU cache in java |
I know it's simple to implement, but I want to reuse something that already exist.
Problem I want to solve is that I load configuration (from XML so I want to cache them) for different pages, roles, ... so the combination of inputs can grow quite much (but in 99% will not). To handle this 1%, I want to have some max n... |
You can use a LinkedHashMap (Java 1.4+) :
// Create cache
final int MAX_ENTRIES = 100;
Map cache = new LinkedHashMap(MAX_ENTRIES+1, .75F, true) {
// This method is called just after a new entry has been added
public boolean removeEldestEntry(Map.Entry eldest) {
return size() > MAX_ENTRIES;
}
};
//... |
How to purge disk I/O caches on Linux? |
I need to do it for more predictable benchmarking.
|
Sounds like you want the sync command, or the sync() function.
If you want disk cache flushing: echo 3 | sudo tee /proc/sys/vm/drop_caches
|
How to make index.html not to cache when the site contents are changes in AngularJS website? |
Normally for .js and .css file we will append a version during build like
xx.js?v=123, and then after website deploy, we can get the new version of js and CSS. But I don't see a place talking about how to make the index.html file upgrade when website deployment happen. And we do see in IE that the HTML content should ... |
Yes, that is the correct way. You have to set the Cache-Control header to let the browsers know that they don't have to cache any content for that request.
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
(Pragma & Cache-Control is one and t... |
Invalidate cache in Picasso |
I load an image from disk using Picasso, e.g., Picasso.with(ctx).load(new File("/path/to/image")).into(imageView), but whenever I save a new image in that file, and refresh my ImageView, Picasso still has the bitmap cached.
Is it possible to invalidate the cache in Picasso?
|
In the recent versions of Picasso, there is a new method for invalidate, without any workarounds, so I think that custom PicassoTools class mentioned earlier, is now obsolete in this case
Picasso.with(getActivity()).invalidate(file);
|
Why is Python list slower when sorted? |
In the following code, I create two lists with the same values: one list unsorted (s_not), the other sorted (s_yes). The values are created by randint(). I run some loop for each list and time it.
import random
import time
for x in range(1,9):
r = 10**x # do different val for the bound in randint()
m = int(r... |
Cache misses. When N int objects are allocated back-to-back, the memory reserved to hold them tends to be in a contiguous chunk. So crawling over the list in allocation order tends to access the memory holding the ints' values in sequential, contiguous, increasing order too.
Shuffle it, and the access pattern when cra... |
How to remove cached server names from the Connect to Server dialog? |
Or, to put it another way, where is SqlStudio.bin for SQL Server 2012? It doesn't seem to be in the place that would be expected by looking at this other SO question.
|
As of SQL Server 2012 you no longer have to go through the hassle of deleting the bin file (which causes other side effects). You should be able to press the Delete key within the MRU list of the Server Name dropdown in the Connect to Server dialog. This is documented in this Connect item and this blog post.
To be cle... |
ASP.NET cache add vs insert |
What is the difference between the Cache.Add() and Cache.Insert() methods?
In which situations should I use each one?
|
Insert will overwrite an existing cached value with the same Key; Add fails (does nothing) if there is an existing cached value with the same key. So there's a case for saying you should always use Insert since the first time the code runs it will put your object into the cache and when it runs subsequently it will up... |
How to avoid AJAX caching in Internet Explorer 11 when additional query string parameters or using POST are not an option |
I realize this question has been asked, but in modern REST practice none of the previous iterations of this question nor their answers are accurate or sufficient. A definitive answer to this question is needed.
The problem is well known, IE (even 11) caches AJAX requests, which is really really dumb. Everyone unders... |
60
Caching is normally controlled through setting headers on the content when it is returned by the server. If you're already doing that and IE is ignoring them and caching anyway, the only way to get around it would be to use one of the cache busting techniques mentioned i... |
ASP.NET MVC how to disable automatic caching option? |
How to disable automatic browser caching from asp.Net mvc application?
Because I am having a problem with caching as it caches all links. But sometimes it redirected to DEFAULT INDEX PAGE automatically
which stored it caching and then all the time I click to that link it will redirect me to DEFAULT INDEX PAGE.
So som... |
You can use the OutputCacheAttribute to control server and/or browser caching for specific actions or all actions in a controller.
Disable for all actions in a controller
[OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)] // will be applied to all actions in MyController, unless those actions over... |
Java's WeakHashMap and caching: Why is it referencing the keys, not the values? |
Java's WeakHashMap is often cited as being useful for caching. It seems odd though that its weak references are defined in terms of the map's keys, not its values. I mean, it's the values I want to cache, and which I want to get garbage collected once no-one else besides the cache is strongly referencing them, no?
In ... |
WeakHashMap isn't useful as a cache, at least the way most people think of it. As you say, it uses weak keys, not weak values, so it's not designed for what most people want to use it for (and, in fact, I've seen people use it for, incorrectly).
WeakHashMap is mostly useful to keep metadata about objects whose lifecyc... |
Advantages of Cache vs Session |
What is the difference between storing a datatable in Session vs Cache? What are the advantages and disadvantages?
So, if it is a simple search page which returns result in a datatable and binds it to a gridview. If user 'a' searches and user 'b' searches, is it better to store it in Session since each user would most... |
One important difference is, that items in the cache can expire (will be removed from cache) after a specified amount of time. Items put into a session will stay there, until the session ends.
ASP.NET can also remove items from cache when the amount of available memory gets small.
Another difference: the session state... |
Is there a way to speedup npm ci using cache? |
for now npm ci is the most common way to install node modules when using CI.
But it is honestly really slow.
Is there a way to speedup npm ci using cache or do not fully remove existing packages (whole node_modules folder)?
|
NPM cache is located in ~/.npm but in most CIs you can only cache things inside your working directory.
What you can do to circumvent this is changing the cache directory to your current directory with npm set cache .npm. The NPM cache will now be located in ./.npm an you can cache this folder between CI jobs.
Example... |
Browser Caching of CSS files |
Quick question regarding CSS and the browser. I tried searching SO and found some similar posts, but nothing definitive.
I use one or two CSS files in my web projects. These are referenced in the HEAD of my web pages. Once I hit one of my pages, does the CSS get cached so that it's not re-downloaded with each request?... |
Your file will probably be cached - but it depends...
Different browsers have slightly different behaviors - most noticeably when dealing with ambiguous/limited caching headers emanating from the server. If you send a clear signal, the browsers obey, virtually all of the time.
The greatest variance by far, is in the d... |
How and when to align to cache line size? |
In Dmitry Vyukov's excellent bounded mpmc queue written in C++
See: http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue
He adds some padding variables. I presume this is to make it align to a cache line for performance.
I have some questions.
Why is it done in this way?
Is it a portable ... |
It's done this way so that different cores modifying different fields won't have to bounce the cache line containing both of them between their caches. In general, for a processor to access some data in memory, the entire cache line containing it must be in that processor's local cache. If it's modifying that data, th... |
ASP.NET MVC OutputCacheAttribute with external cache providers |
After switching an ASP.NET MVC 5 application to Azure Redis (Microsoft.Web.RedisOutputCacheProvider Nuget package) I was surprised to see that OutputCacheAttribute when set to use either OutputCacheLocation.Any or OutputCacheLocation.ServerAndClient
[Route("Views/Orders")]
[OutputCache(Duration = 600, Location = Outpu... |
1
The issue is that if the endpoint is authenticated, then by definition the output varies by the user. So basically all external output cache providers are no longer an option.
Your options are either:
Unprotect the endpoints if they could allow anonymous safely
Use local... |
Aligning to cache line and knowing the cache line size |
To prevent false sharing, I want to align each element of an array to a cache line. So first I need to know the size of a cache line, so I assign each element that amount of bytes. Secondly I want the start of the array to be aligned to a cache line.
I am using Linux and 8-core x86 platform. First how do I find the c... |
To know the sizes, you need to look it up using the documentation for the processor, afaik there is no programatic way to do it. On the plus side however, most cache lines are of a standard size, based on intels standards. On x86 cache lines are 64 bytes, however, to prevent false sharing, you need to follow the guide... |
Chrome doesn't cache images/js/css |
When Chrome loads my website, it checks the server for updated versions of files before it shows them. (Images/Javascript/CSS) It gets a 304 from the server because I never edit external javascript, css or images.
What I want it to do, is display the images without even checking the server.
Here are the headers:
Conne... |
121
Make sure you have the disable cache checkbox unchecked/disabled in the Developer Tools.
Share
Improve this answer
Follow
edited Feb 2, 2021 at 6:36
Rob Bednark
26.8k2424 gold badges8282 silver ba... |
The correct way to delete all files older than 2 days in PHP |
Just curious:
$files = glob(cacheme_directory() . '*');
foreach ($files as $file) {
$filemtime = filemtime($file);
if (time() - $filemtime >= 172800) {
unlink($file);
}
}
I just want to make sure if the code is correct or not. Thanks.
|
You should add an is_file() check, because sub-directories could reside in the the directory you're checking.
Also, as this answer suggests, you should replace the pre-calculated seconds with a more expressive notation.
$files = glob(cacheme_directory() . '*');
$threshold = strtotime('-2 day');
foreach ($files as $... |
How to use HTTP cache headers with PHP |
I have a PHP 5.1.0 website (actually it's 5.2.9 but it must also run on 5.1.0+).
Pages are generated dynamically but many of them are mostly static. By static I mean the content don't change but the "template" around the content can change over time.
I know they are several cache systems and PHP frameworks already out... |
You might want to use private_no_expire instead of private, but set a long expiration for content you know is not going to change and make sure you process if-modified-since and if-none-match requests similar to Emil's post.
$tsstring = gmdate('D, d M Y H:i:s ', $timestamp) . 'GMT';
$etag = $language . $timestamp;
$i... |
Check whether network response is coming from server or Chrome cache |
In Google Chrome, how you can check which files are served from the browser cache, and which comes from the server?
|
In Chrome Developer Tools switch to the Network tab and on the Size column it will either give you the size of the downloaded content or say (from disk/memory cache).
|
How long does Google Chrome cache a resource if expires and/or no-cache headers are not set? |
We have been having a problem with Chrome caching a resource on our Glassfish server. The expires and no-cache headers are not being sent and the resource (an approximately 4 MB SWF file) is being cached by Chrome -- despite the presence of the Last-Modified header.
Sometimes Chrome will get a 304 code, and other time... |
26
The time the browser considers a cached response fresh is usually relative to when it was last modified:
Since origin servers do not always provide explicit expiration times, a cache MAY assign a heuristic expiration time when an explicit time is not specified, employin... |
How do you set cache headers in Spring MVC? |
In an annotation-based Spring MVC controller, what is the preferred way to set cache headers for a specific path?
|
org.springframework.web.servlet.support.WebContentGenerator, which is the base class for all Spring controllers has quite a few methods dealing with cache headers:
/* Set whether to use the HTTP 1.1 cache-control header. Default is "true".
* <p>Note: Cache headers will only get applied if caching is enabled
* (or ex... |
What is a distributed cache? |
I am confused about the concept of Distributed Cache. I kinda know what it is from google search. A distributed cache may span multiple servers so that it can grow in size and in transactional capacity. However, I do not really understand how it works or how it distribute the data.
For example, let's say we have Dat... |
Yes, half the data on server a, and half on server b would be a distributed cache. There are many methods of distributing the data, though some sort of hashing of the keys seems to be most popular.
The terms server and node are generally interchangeable. A node is generally a single unit of some collection, often ca... |
Clear the cache from the Rails asset pipeline |
I'm starting a new project in Rails, and it looks like the application.js manifest file is doing something funny with the javascripts that I reference - does it cache those files as part of the asset pipeline?
Here's what happened. I added a javascript file named jquery.autoresize.js to the vendor/assets/javascripts f... |
I'm assuming we're talking about the production environment.
When you change any of your javascripts or stylesheets in the production environment, you need to run rake assets:precompile; this task compiles and compresses the various .js and .css files and creates the application.js and application.css files that is l... |
.NET Caching how does Sliding Expiration work? |
If I use an ObjectCache and add an item like so:
ObjectCache cache = MemoryCache.Default;
string o = "mydata";
cache.Add("mykey", o, DateTime.Now.AddDays(1));
I understand the object will expire in 1 day. But if the object is accessed 1/2 a day later using:
object mystuff = cache["mykey"];
Does this reset the timer ... |
There are two types of cache policies you can use:
CacheItemPolicy.AbsoluteExpiration will expire the entry after a set amount of time.
CacheItemPolicy.SlidingExpiration will expire the entry if it hasn't been accessed in a set amount of time.
The ObjectCache Add() overload you're using treats it as an absolute expi... |
Safari 7 application cache does not work |
In Safari 7, the main html file with a manifest is loadable when offline, but none of the external resources are loaded, even if they're listed in the manifest file as cached. Safari's resource pane lists the files as in the application cache, but it will not load them. I've tried an extremely simple test, checked MIM... |
1
Clear Cache in Safari version 7 on Mac OSX
You have two options to clear the cache in Safari version 6:
Use the "Empty Caches" option
Select which items you want to clear by using the "Reset" option
Share
Improve this answer
Follow
... |
Google chrome css doesn't update unless clear cache |
I'm trying to work in my local server but I have to clear my cache every time if I want to see changes on the css rules.
There is any way to control Google Chrome cache?
|
Open DevTools
Open Settings (bottom right or use F1 shortcut)
Check Disable cache (while DevTools is open)
https://developers.google.com/chrome-developer-tools/docs/settings#general
|
How to limit the size of a dictionary? |
I'd like to work with a dict in python, but limit the number of key/value pairs to X. In other words, if the dict is currently storing X key/value pairs and I perform an insertion, I would like one of the existing pairs to be dropped. It would be nice if it was the least recently inserted/accesses key but that's not c... |
Python 2.7 and 3.1 have OrderedDict and there are pure-Python implementations for earlier Pythons.
from collections import OrderedDict
class LimitedSizeDict(OrderedDict):
def __init__(self, *args, **kwds):
self.size_limit = kwds.pop("size_limit", None)
OrderedDict.__init__(self, *args, **kwds)
... |
How can I make the browser see CSS and Javascript changes? |
CSS and Javascript files don't change very often, so I want them to be cached by the web browser. But I also want the web browser to see changes made to these files without requiring the user to clear their browser cache. Also want a solution that works well with a version control system such as Subversion.
Some sol... |
I found that if you append the last modified timestamp of the file onto the end of the URL the browser will request the files when it is modified. For example in PHP:
function urlmtime($url) {
$parsed_url = parse_url($url);
$path = $parsed_url['path'];
if ($path[0] == "/") {
$filename = $_SERVER['DOCU... |
C++ cache aware programming |
is there a way in C++ to determine the CPU's cache size? i have an algorithm that processes a lot of data and i'd like to break this data down into chunks such that they fit into the cache. Is this possible?
Can you give me any other hints on programming with cache-size in mind (especially in regard to multithreaded/m... |
17
According to "What every programmer should know about memory", by Ulrich Drepper you can do the following on Linux:
Once we have a formula for the memory
requirement we can compare it with the
cache size. As mentioned before, the
cache might be shared with multipl... |
Convert a File Object to Bitmap |
I am using Universal-Image-Loader and there is this functionality that access the file cache of the image from sd card. But I don't know how to convert the returned file cache into bitmap. Basically I just wanted to assign the bitmap to an ImageView.
File mSaveBit = imageLoader.getDiscCache().get(easyPuzzle);
Log.d("... |
You should be able to use BitmapFactory:
File mSaveBit; // Your image file
String filePath = mSaveBit.getPath();
Bitmap bitmap = BitmapFactory.decodeFile(filePath);
mImageView.setImageBitmap(bitmap);
|
Spring cache @Cacheable method ignored when called from within the same class |
I'm trying to call a @Cacheable method from within the same class:
@Cacheable(value = "defaultCache", key = "#id")
public Person findPerson(int id) {
return getSession().getPerson(id);
}
public List<Person> findPersons(int[] ids) {
List<Person> list = new ArrayList<Person>();
for (int id : ids) {
list... |
This is because of the way proxies are created for handling caching, transaction related functionality in Spring. This is a very good reference of how Spring handles it - Transactions, Caching and AOP: understanding proxy usage in Spring
In short, a self call bypasses the dynamic proxy and any cross cutting concern li... |
Cache busting with CRA React |
When I updated my site, run npm run build and upload the new files to the server I am still looking the old version of my site.
Without React, I can see the new version of my site with cache-busting. I do this:
Previous file
<link rel="stylesheet" href="/css/styles.css">
New file
<link rel="stylesheet" href="/css... |
EDIT: create-react-app v2 now have the service worker disabled by default
This answer only apply for CRA v1
This is probably because of your web worker.
If you look into your index.js file you can see
registerServiceWorker();
Never wondered what it did? If we take a look at the file it got imported from we can see
... |
How to force DNS refresh for a website? |
I'm moving my web application to another server and in the next few days I'll refresh the DNS to point to the new IP location.
Unfortunately some browsers and SOs keep a DNS cache that will make users point to the old IP location. Some users are rookies and they'll not refresh the DNS cache manually and I know we'll l... |
As far as I know, a forced update like this is not directly possible. You might be able to reduce the DNS downtime by reducing the TTL (Time-To-Live) value of the entries before changing them, if your name server service provider allows that.
Here's a guide for less painful DNS changes.
A fair warning, though - not al... |
How to disable caching from NSURLSessionTask |
In my iOS app, I am using NSURLSessionTask to download json data to my app. I discovered that when I call the url directly from the browser, I get an up to date json and when it's called from within the app, I get an older version of the json.
Is this due to caching? How can I tell NSURLSessionTask to not use caching.... |
If your read the links from @runmad you can see in the flow chart that if the HEAD of the file is unchanged it will still used the cached version when you set the cachePolicy.
In Swift3 I had to do this to get it to work:
let config = URLSessionConfiguration.default
config.requestCachePolicy = .reloadIgnoringLocalCach... |
How to clear browser cache with php? |
How to clear browser cache with php?
|
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: application/xml; charset=utf-8");
|
Better Way to Prevent IE Cache in AngularJS? |
I currently use service/$resource to make ajax calls (GET in this case), and IE caches the calls so that fresh data cannot be retrieved from the server. I have used a technique I found by googling to create a random number and append it to the request, so that IE will not go to cache for the data.
Is there a better w... |
As binarygiant requested I am posting my comment as an answer. I have solved this problem by adding No-Cache headers to the response on server side. Note that you have to do this for GET requests only, other requests seems to work fine.
binarygiant posted how you can do this on node/express. You can do it in ASP.NET M... |
How to avoid caching when values are null? |
I am using Guava to cache hot data. When the data does not exist in the cache, I have to get it from database:
public final static LoadingCache<ObjectId, User> UID2UCache = CacheBuilder.newBuilder()
//.maximumSize(2000)
.weakKeys()
.weakValues()
.expireAfterAccess(10, TimeUnit.MINUTES)
... |
Just throw some Exception if user is not found and catch it in client code while using get(key) method.
new CacheLoader<ObjectId, User>() {
@Override
public User load(ObjectId k) throws Exception {
User u = DataLoader.datastore.find(User.class).field("_id").equal(k).get();
if (u != null) {
... |
Load index.html every time from the server and NOT from cache |
I have a webpage index.html hosted on a particular server. I have pointed example.com to example.com/index.html. So when I make changes in index.html and save it, and then try to open example.com, the changes are not reflected. Reason that the webpages are being cached.
Then I manually refresh the page and since it lo... |
by this:
<meta http-equiv="expires" content="0">
Setting the content to "0" tells the browsers to always load the page from the web server.
|
Sencha Touch 2 PhoneGap issue for 4.0.x |
I have an Android HTC Amaze and an Android HTC Desire. My Sencha Touch 2 apps wrapped by PhoneGap work excellent for the Desire but they refuse to load on the HTC Amaze 4.0.3.
I'm getting this kind of errors in log -
08-24 17:08:37.577: E/chromium(16106): external/chromium/net/disk_cache/stat_hub.cc:190: [0824/170837... |
1
Try to update cordova version as latest one.
cordova -v
npm install -g cordova
current recent cordova version is 8.x.
and please check which cordova plugins are installed.
Share
Improve this answer
Follow
... |
Saving image and then loading it in Swift (iOS) |
I am saving an image using saveImage.
func saveImage (image: UIImage, path: String ) -> Bool{
let pngImageData = UIImagePNGRepresentation(image)
//let jpgImageData = UIImageJPEGRepresentation(image, 1.0) // if you want to save as JPEG
print("!!!saving image at: \(path)")
let result = pngImageData... |
77
This function will save an image in the documents folder:
func saveImage(image: UIImage) -> Bool {
guard let data = UIImageJPEGRepresentation(image, 1) ?? UIImagePNGRepresentation(image) else {
return false
}
guard let directory = try? FileManager.d... |
Caching query results in django |
I'm trying to find a way to cache the results of a query that won't change with frequency. For example, categories of products from an e-commerce (cellphones, TV, etc).
I'm thinking of using the template fragment caching, but in this fragment, I will iterate over a list of these categories. This list is avaliable in a... |
Pop your cached query into Django's cache:
from django.core.cache import cache
cache.set('key', queryset)
Then create a context processor to add the value of the cache to all templates:
# myproject/myapp/context_processors.py
from django.core.cache import cache
def cached_queries():
return {'cache', cache.get(... |
Memcache vs Java Memory |
Simple, probably dumb question: Suppose I have a Java server that stores in memory commonly used keys and values which I can query (let's say in a HashMap)
What's the difference between that and using Memcache (or even Redis)? They both store things in memory. Is there a benefit to one or the other? Does Memcache leav... |
Advantages of Java memory over memcache:
Java memory is faster (no network).
Java memory won't require serialization, you have Java objects available to you.
Advantages of memcache over Java memory:
It can be accessed by more than one application server, so your cache will be shared among all your app servers.
It c... |
What else can throw a ClassCastException in java? |
This is an interview question.
The interview is over, but this question is still on my mind.
I can't ask the interviewer, as I did not get the job.
Scenario:
put object of class C1 in to a cache with key "a"
Later code:
C1 c1FromCache = (C1) cache.get("a");
This code throws a ClassCastException.
What can the reaso... |
One reason could be that the part of the code inserting the object uses a different classloader than the code retrieving it.
An instance of a class can not be cast to the same class loaded by a different classloader.
Response to the edit:
What would you do if this happened in production?
This generally happens when ... |
caching JavaScript files |
Which is the best method to make the browser use cached versions of js files (from the serverside)?
|
Have a look at Yahoo! tips: https://developer.yahoo.com/performance/rules.html#expires.
There are also tips by Google: https://developers.google.com/speed/docs/insights/LeverageBrowserCaching
|
Which PHP opcode cacher should I use to improve performance? [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 ... |
I think the answer might depend on the type of web applications you are running. I had to make this decision myself two years ago and couldn't decide between Zend Optimizer and eAccelerator.
In order to make my decision, I used ab (apache bench) to test the server, and tested the three combinations (zend, eaccelerator... |
How to disable caching of single page application HTML file served through IIS? |
I have a single page application (angular-js) which is served through IIS. How do I prevent caching of HTML files? The solution needs to be achieved by changing content within either index.html or the web.config, as access to IIS through a management console is not possible.
Some options I am currently investigating a... |
Adding the following into web.config solution worked across Chrome, IE, Firefox, and Safari:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="index.html">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="no-cache" />
</custo... |
Expiry time @cacheable spring boot |
I have implemented a cache and now I want to add an expiry time.
How can I set an expiry time in spring boot with @Cacheable?
This is a code snippet:
@Cacheable(value="forecast",unless="#result == null")
|
38
I use life hacking like this:
@Configuration
@EnableCaching
@EnableScheduling
public class CachingConfig {
public static final String GAMES = "GAMES";
@Bean
public CacheManager cacheManager() {
ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheMa... |
Is MemoryCache scope session or application wide? |
I'm using MemoryCache in ASP.NET and it is working well. I have an object that is cached for an hour to prevent fresh pulls of data from the repository.
I can see the caching working in debug, but also once deployed to the server, after the 1st call is made and the object is cached subsequent calls are about 1/5 of th... |
From MSDN:
The main differences between the Cache and MemoryCache classes are
that the MemoryCache class has been changed to make it usable by .NET
Framework applications that are not ASP.NET applications. For example,
the MemoryCache class has no dependencies on the System.Web assembly.
Another difference is... |
Chrome keeps loading a old cache of my website |
I am experiencing this weird issue where my Chrome browser keeps loading a old version of my website whose code doesn't even exist on my server any more. I assume it's a typical cache issue.
I tried to clean the browser cache, use igcognito mode, and clean DNS cache. The old cached page is still being loaded.
This iss... |
16
<?php Header("Cache-Control: max-age=3000, must-revalidate"); ?>
You can implement a PHP script that must be the first line of code in your index file . It is an http header typically issued by web servers. You can also rename the resource that is considered "stale". ... |
MVC4 StyleBundle: Can you add a cache-busting query string in Debug mode? |
I've got an MVC application and I'm using the StyleBundle class for rendering out CSS files like this:
bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/*.css"));
The problem I have is that in Debug mode, the CSS urls are rendered out individually, and I have a web proxy that aggressively caches these u... |
You can create a custom IBundleTransform class to do this. Here's an example that will append a v=[filehash] parameter using a hash of the file contents.
public class FileHashVersionBundleTransform: IBundleTransform
{
public void Process(BundleContext context, BundleResponse response)
{
foreach(var fil... |
How to disable caching in Alamofire |
When I send a GET request twice with Alamofire I get the same response but I'm expecting a different one. I was wondering if it was because of the cache, and if so I'd like to know how to disable it.
|
swift 3, alamofire 4
My solution was:
creating extension for Alamofire:
extension Alamofire.SessionManager{
@discardableResult
open func requestWithoutCache(
_ url: URLConvertible,
method: HTTPMethod = .get,
parameters: Parameters? = nil,
encoding: ParameterEncoding = URLEncodin... |
Disabling caching in Flask [duplicate] |
This question already has answers here:
Using Flask, how do I modify the Cache-Control header for ALL output?
(3 answers)
Closed 2 years ago.
I have some caching issues. I'm runnin... |
OK,
finally it worked with this:
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.