Questions tagged [caching]

A cache is a mechanism for temporarily storing (caching) data locally in order to reduce access time to data stored far away. For CPU/disk/web browsing please use relevant tags (cpu-cache, diskcache,...)

A cache is a mechanism that involves temporarily storing data in places that are faster to access than the original storage location. can be machine code instructions, images, documents, or web pages, for example. The purpose of a cache is to reduce access time, bandwidth usage, server load, and perceived lag.

Different applications where cache mechanisms are used include:

Useful Links

37958 questions
171
votes
4 answers

What is Cache-Control: private?

When I visit chesseng.herokuapp.com I get a response header that looks like Cache-Control:private Connection:keep-alive Content-Encoding:gzip Content-Type:text/css Date:Tue, 16 Oct 2012 06:37:53 GMT Last-Modified:Tue, 16 Oct 2012 03:13:38…
user782220
  • 10,677
  • 21
  • 72
  • 135
170
votes
5 answers

Write-back vs Write-Through caching?

My understanding is that the main difference between the two methods is that in "write-through" method data is written to the main memory through the cache immediately, while in "write-back" data is written in a "later time". We still need to wait…
triple fault
  • 13,410
  • 8
  • 32
  • 45
165
votes
7 answers

Memcached vs APC which one should I choose?

I read this article: http://www.mysqlperformanceblog.com/2006/09/27/apc-or-memcached/ from way back when.. I want to get the best caching engine available so that my application is really fast. Of course I don't want to over-cache but I want to at…
Thomaschaaf
  • 17,847
  • 32
  • 94
  • 128
165
votes
5 answers

How to prevent caching of my Javascript file?

I have a simple html:
Bdfy
  • 23,141
  • 55
  • 131
  • 179
164
votes
5 answers

What is the difference between Caching and Memoization?

I would like to know what the actual difference between caching and memoization is. As I see it, both involve avoiding repeated function calls to get data by storing it. What's the core difference between the two?
John
  • 1,643
  • 2
  • 10
  • 4
164
votes
3 answers

What is the "Temporary ASP.NET Files" folder for?

I've discovered this folder in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and have a few questions. What does ASP.NET use this folder for, and what sort of files are stored here? How does a file get stored here, and when…
Alex Angas
  • 59,219
  • 41
  • 137
  • 210
163
votes
3 answers

How do I request a file but not save it with Wget?

I'm using Wget to make http requests to a fresh web server. I am doing this to warm the MySQL cache. I do not want to save the files after they are served. wget -nv -do-not-save-file $url Can I do something like -do-not-save-file with wget?
T. Brian Jones
  • 13,002
  • 25
  • 78
  • 117
162
votes
14 answers

How to programmatically empty browser cache?

I am looking for a way to programmatically empty the browser cache. I am doing this because the application caches confidential data and I'd like to remove those when you press "log out". This would happen either via server or JavaScript. Of course,…
Tower
  • 98,741
  • 129
  • 357
  • 507
158
votes
7 answers

Can Retrofit with OKHttp use cache data when offline

I'm trying to use Retrofit & OKHttp to cache HTTP responses. I followed this gist and, ended up with this code: File httpCacheDirectory = new File(context.getCacheDir(), "responses"); HttpResponseCache httpResponseCache = null; try { …
osrl
  • 8,168
  • 8
  • 36
  • 57
157
votes
6 answers

How to prevent browser page caching in Rails

Ubuntu → Apache → Phusion Passenger → Rails 2.3. The main part of my site reacts to your clicks. So, if you click on a link, it will send you on to the destination, and instantly regenerate your page. But, if you hit the back button, you don't see…
Jason Butler
  • 5,619
  • 3
  • 22
  • 18
155
votes
12 answers

Cache busting via params

We want to cache bust on production deploys, but not waste a bunch of time off the bat figuring out a system for doing so. My thought was to apply a param to the end of css and js files with the current version number:
Brad Herman
  • 9,665
  • 7
  • 28
  • 30
154
votes
4 answers

Redis: possible to expire an element in an array or sorted set?

Is it currently only possible to expire an entire key/value pair? What if I want to add values to a List type structure and have them get auto removed 1 hour after insertion. Is that currently possible, or would it require running a cron job to do…
randombits
  • 47,058
  • 76
  • 251
  • 433
154
votes
20 answers

How to force a web browser NOT to cache images

Background I am writing and using a very simple CGI-based (Perl) content management tool for two pro-bono websites. It provides the website administrator with HTML forms for events where they fill the fields (date, place, title, description, links,…
Philibert Perusse
  • 4,026
  • 5
  • 24
  • 26
153
votes
13 answers

Why both no-cache and no-store should be used in HTTP response?

I'm told to prevent user-info leaking, only "no-cache" in response is not enough. "no-store" is also necessary. Cache-Control: no-cache, no-store After reading this spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, I'm still not quite…
Morgan Cheng
  • 73,950
  • 66
  • 171
  • 230
153
votes
1 answer

Private vs Public in Cache-Control

Can you please describe an example indicating difference between Public and Private Cache-Control in asp.net applications hosted in IIS. I read in MSDN that the difference is the following: Public: Sets Cache-Control: public to specify that the…
ppolyzos
  • 6,791
  • 6
  • 31
  • 40