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

35446 questions
192
votes
22 answers

Clear the cache in JavaScript

How do I clear a browsers cache with JavaScript? We deployed the latest JavaScript code but we are unable to get the latest JavaScript code. Editorial Note: This question is semi-duplicated in the following places, and the answer in the first of the…
subramani
189
votes
5 answers

How do cache lines work?

I understand that the processor brings data into the cache via cache lines, which - for instance, on my Atom processor - brings in about 64 bytes at a time, whatever the size of the actual data being read. My question is: Imagine that you need to…
Norswap
  • 10,130
  • 10
  • 42
  • 57
185
votes
12 answers

What is the difference between buffer and cache memory in Linux?

To me it's not clear what's the difference between the two Linux memory concepts : buffer and cache. I've read through this post and it seems to me that the difference between them is the expiration policy: buffer's policy is first-in,…
James.Xu
  • 8,023
  • 5
  • 23
  • 35
183
votes
18 answers

Is there a decorator to simply cache function return values?

Consider the following: @property def name(self): if not hasattr(self, '_name'): # expensive calculation self._name = 1 + 1 return self._name I'm new, but I think the caching could be factored out into a decorator. Only I…
Tobias
  • 3,150
  • 2
  • 19
  • 25
182
votes
8 answers

Programmatically get the cache line size?

All platforms welcome, please specify the platform for your answer. A similar question: How to programmatically get the CPU cache page size in C++?
paxos1977
  • 135,245
  • 26
  • 85
  • 125
182
votes
8 answers

Laravel 5 Clear Views Cache

I notice that Laravel cache views are stored in ~/storage/framework/views. Over time, they get to eat up my space. How do I delete them? Is there any command that could? I tried php artisan cache:clear, but it is not clearing the views cache. With…
basagabi
  • 4,248
  • 6
  • 29
  • 62
171
votes
18 answers

How to clear APC cache entries?

I need to clear all APC cache entries when I deploy a new version of the site. APC.php has a button for clearing all opcode caches, but I don't see buttons for clearing all User Entries, or all System Entries, or all Per-Directory Entries. Is it…
lo_fye
  • 6,728
  • 2
  • 30
  • 49
171
votes
21 answers

How would you implement an LRU cache in Java?

Please don't say EHCache or OSCache, etc. Assume for purposes of this question that I want to implement my own using just the SDK (learning by doing). Given that the cache will be used in a multithreaded environment, which datastructures would you…
Hank Gay
  • 65,372
  • 31
  • 148
  • 218
167
votes
15 answers

How does one write code that best utilizes the CPU cache to improve performance?

This could sound like a subjective question, but what I am looking for are specific instances, which you could have encountered related to this. How to make code, cache effective/cache friendly (more cache hits, as few cache misses as possible)?…
goldenmean
  • 16,908
  • 50
  • 144
  • 206
167
votes
3 answers

Clear MySQL query cache without restarting server

Is there any way to clear mysql query cache without restarting mySQL server?
Mahoor13
  • 4,649
  • 5
  • 20
  • 21
163
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,014
  • 31
  • 90
  • 122
162
votes
3 answers

Notepad++ cached files location

On the most recent versions of Notepad++, when the application is closed, unsaved files are maintained when the application is restarted. I presume that those files are cached on a temporary files. What is the location of that file(s). Thank you
RedEagle
  • 4,008
  • 9
  • 38
  • 62
159
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
  • 56,458
  • 39
  • 130
  • 203
159
votes
24 answers

How to force Chrome browser to reload .css file while debugging in Visual Studio?

I'm currently editing a .css file inside of Visual Studio 2012 (in debug mode). I'm using Chrome as my browser. When I make changes to my application's .css file inside of Visual Studio and save, refreshing the page will not load with the updated…
duyn9uyen
  • 7,733
  • 12
  • 36
  • 47
158
votes
2 answers

Redis cache vs using memory directly

I have not used Redis yet, but I heard about it and plan to try it as cache storing. I heard Redis using memory as cache store database, so what's the difference if I use a variable as an object or dictionary datatype to store data? like: var cache…
hh54188
  • 13,085
  • 30
  • 99
  • 174