Questions tagged [caching]

Questions regarding cache algorithms by applications and implementations of information caching by database engines and other information repository and presentation applications.

248 questions
610
votes
13 answers

So Singletons are bad, then what?

There has been a lot of discussion lately about the problems with using (and overusing) Singletons. I've been one of those people earlier in my career too. I can see what the problem is now, and yet, there are still many cases where I can't see a…
62
votes
6 answers

Why is CPU cache memory so fast?

What makes CPU cache memory so much faster than main memory? I can see some benefit in a tiered cache system. It makes sense that a smaller cache is faster to search. But there must be more to it.
ConditionRacer
  • 5,682
  • 6
  • 38
  • 56
44
votes
3 answers

Caching at business layer vs Caching at Data Layer

I have always worked on projects where caching was done on DAL, basically just when you are about to make the call to database, it checks if data is already there in the cache and if it is, it just doesn't make the call and instead returns that…
Emma
  • 645
  • 1
  • 6
  • 9
35
votes
9 answers

How can QA staff test caching logic that they can't see?

I just implemented a caching layer in my web application, and now I'm wondering how QA is supposed to test it, since caching is transparent to the user. One idea I have is to put logging in the methods that invoke the code that populate the cache,…
Joshua Frank
  • 599
  • 1
  • 4
  • 9
33
votes
2 answers

Writing low latency Java

Are there any Java-specific techniques (things which wouldnt apply to C++) for writing low latency code, in Java? I often see Java low latency roles and they ask for experience writing low latency Java- which sometimes seems a little bit of an…
user997112
  • 1,469
  • 2
  • 19
  • 24
31
votes
3 answers

Dealing with browser cache in single-page apps

I'm trying to figure out how to properly handle the web browser cache for single page apps. I have a fairly typical design: several HTML, JS and CSS files implementing the SPA, and a bunch of JSON data that's consumed by the SPA. Problems arise when…
Josh Kelley
  • 10,991
  • 7
  • 38
  • 50
20
votes
6 answers

Best practices for unit testing methods that use cache heavily?

I have a number of business logic methods that store and retrieve (with filtering) objects and lists of objects from cache. Consider IList AllFromCache() { ... } TObject FetchById(guid id) { ... } IList FilterByPropertry(int…
NikolaiDante
  • 888
  • 3
  • 8
  • 24
15
votes
2 answers

Using Memcached: is it good practice to update the cache when updating the database?

This question is about best practices in architecture. Our Current Architecture I have a PHP class that accesses MySQL for user info. Let's call it User. User is accessed many times, so we have implemented layers of caching to reduce load. The…
Stephen
  • 2,200
  • 6
  • 22
  • 24
15
votes
4 answers

What is important when optimising for the CPU cache (in C)?

Reading these two questions, I see that understanding CPU caching behaviour can be important when dealing with large amounts of data in memory. I would like to understand the way the caching works to add another tool to my optimisation toolbox. What…
Timothy Jones
  • 261
  • 1
  • 2
  • 7
14
votes
5 answers

How can I efficiently diff a CSV file against a database?

I have an inventory of products stored in Postgres. I need to be able to take a CSV file and get a list of changes—the things in the CSV file that are different to what is in the database. The CSV file has about 1.6 million rows. The naive approach…
Isvara
  • 610
  • 6
  • 18
14
votes
1 answer

Why do some websites showing 0 bytes in Chrome's developer tools

I am doing a page speed optimization for my website and studying how other websites do it. I noticed that some websites such as as Facebook or Ringgitplus show 0 bytes for some of their resources in Chrome's developer tools, Network tab, while the…
kecebongsoft
  • 433
  • 4
  • 7
14
votes
2 answers

Shared Cache - Invalidation Best Practice

I'd like to know what would be a better approach to invalidate/update cache objects. Prerequisites Having remote memcached server (serving as cache for multiple applications) All servers are hosted by azure (affinity regions, same data…
lurkerbelow
  • 1,009
  • 1
  • 10
  • 19
14
votes
2 answers

Random Cache Expiry

I've been experimenting with random cache expiry times to avoid situations where an individual request forces multiple things to update at once. For example, a web page might include five different components. If each is set to time out in 30…
mahemoff
  • 503
  • 2
  • 10
13
votes
5 answers

Most Efficient Cache Replacement Algorithm

Wikipedia lists 11 cache replacement algorithms. Assuming I know almost nothing about the application I'm going to develop, what should I use as a "default" cache replacement algorithm? If I recall correctly from my OS course, LRU is the best…
ashes999
  • 1,129
  • 5
  • 12
  • 22
13
votes
3 answers

Why are requests for static content being sent to another site?

Whenever I login to stackoverflow or some sites I see lots of requests for sites like http://cdn.sstatic.net/. Why is this done rather than serving directly from the actual site? How does it help to speed up a website?
S L
  • 315
  • 3
  • 8
1
2 3
16 17