To cache or not to cache

It's a well known fact that it's a good practice to cache results of SQL queries. But here as everywhere we should limit ourselfs and not to cache everything, shouldn't we? ) For example, you know that in facebook you can enter information about yourself - first name, last name, all your schools, jobs and so on. This data changes very rarely. So, as books say this data is perfect to be cached. But, you see, there can be millions of users with there profiles in our cache. So.. to cache or not to cache? )

0
AxelTv
5/14/2008 8:40:55 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

12 Replies
1019 Views

Similar Articles

[PageSpeed] 59

 it is a good practice to use limited size content and low edit frequency items


سیستم آموزش مجازی
سیستم مدیریت کتابخانه دیجیتال
وستا
گزارش ساز
0
Mojtaabaa
5/14/2008 9:06:59 AM

Here we have few millions small size items with low edit frequency.

0
AxelTv
5/14/2008 9:10:32 AM

so there is a balance between resources and performance.

if your sql server is quick  and data is calculated quick enough then it is better to not cache because it won't improve performance.

but the cache may decrease performance in some cases so consider to cache what and when?


سیستم آموزش مجازی
سیستم مدیریت کتابخانه دیجیتال
وستا
گزارش ساز
0
Mojtaabaa
5/19/2008 11:49:43 AM

AxelTv:

It's a well known fact that it's a good practice to cache results of SQL queries. But here as everywhere we should limit ourselfs and not to cache everything, shouldn't we? ) For example, you know that in facebook you can enter information about yourself - first name, last name, all your schools, jobs and so on. This data changes very rarely. So, as books say this data is perfect to be cached. But, you see, there can be millions of users with there profiles in our cache. So.. to cache or not to cache? )

It's only good practice to cache the results where appropriate.

If you were to cache ALL the personal data for everyone in facebook, the cache would be HUGE and probably very inefficient.  Much better off to suffer a database hit for that, which is inherently more scalable.

Caching is an art-form.

0
Mr
5/19/2008 12:15:20 PM

for that kind of things, use the SqlCacheDependency Class.


good luck coding,
VQ
0
vargquiron
5/19/2008 2:53:55 PM

No satisfactory answer, indeed it's very good question, i am also interested to see the replys


If this post helps you, please mark it as Answer.



Cheers,
Muhammad Rizwan Javed
Sr .Net Developer
Aim 168, Dubai, UAE.
0
Rizwan328
5/19/2008 2:56:56 PM

some times it is better to use output caching for page instead of caching the result.you can see the microsoft enterprise library - caching application block for another caching solution .


سیستم آموزش مجازی
سیستم مدیریت کتابخانه دیجیتال
وستا
گزارش ساز
0
Mojtaabaa
5/20/2008 7:55:25 AM

hi if you are using asp.net 2.0 then you can go for SqlCacheDependency.

where the data is cached until the data gets changed..hope this may answer you. correct me if i'm wrong.

below is the link where you can find the tutorial about that

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/caching/SQLInvalidation.aspx

Yes


With Thanks.,
R.Chezhian.,
=============================================
Please Mark the helpful post(s) as Answered
0
chezhian_in05
5/20/2008 11:22:56 AM

>So.. to cache or not to cache? If the backend database is SQL Server, then generally writing cache code is unnecessary as SQL will cache items in memory. However as pointed out already SQLDependency can be used effectively for certain types of query to force the re-evaluation of a cached item.

For situations where data access is much slower, there may be cases when caching data even for a few seconds gives an enormous improvement in performance once the initial query has run. 


Don't forget to click "Mark as Answer" on the post that helped you.
This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
0
TATWORTH
5/20/2008 11:44:43 AM

I think this has been said here, but the answer to your question is that on a public-facing application, you cache when caching offers an demonstrable advantage, and you don't cache if it doesn't.  A demonstrable advantage may be in performance -- how long it takes the data to be retreived and downloaded to the client, or some other tangible improvement for the client or for additional data processing.

Speed cannot be taken as simple speed; there's the offset of how many server resources you are consuming under maximum assumed load and how much of the servers' resources are available.  Where caching may be fast under low-to-moderate demands on a high resource server, high demand may slow everything down as the availabel server resources become the bottleneck, and when the resources are sufficiently consumed, Windows will start dumping the cache anyway.

This is only My Humblest Opinion, and is not intended as an answer, but in general, I only cache data when I know I have more processing to do with it; for example, I only count on cached data when I know the client may decide to sort it, or if there are alternative data displays they may choose.  For the obvious reason that if I try to hold a large amount of data in cache, either in the application or SQL Server, chances are I'm going to lose it if and when the demand on either server increases.

In the instant question you asked about Face Book, how long you could hold that much data in cache depends on the server(s) and the number of clinets attached at any given moment.  My guess would be "Not very long..."

 

 

0
T
5/20/2008 2:20:06 PM

i think you should use a profiler to see the diffrence when you use cashe and you don't use cache.

you can use open source profilers or third part profilers like ants profiler or so on.

if cache improves your performance then you should consider the situation.

there is not any public and general situation for this question.it depends on situation.

what would you say to some one who ask you "marry or not marry?" .Big Smile

so everyone should decide himself/herself.it has some guidelines that are presented in this discussion and in the web but they can't help you to decide certainly.they can help you to consider the situation.
 

 


 


سیستم آموزش مجازی
سیستم مدیریت کتابخانه دیجیتال
وستا
گزارش ساز
0
Mojtaabaa
5/22/2008 4:35:31 AM

Caching is a good practice when content do not change frequently and all depends on the content which we are caching, we must not cache the private information of the users rather we must cache the public content because public content is shared with all users, whereas private content like First name, last name, email, school information etc sort of stuff is different for every user and caching as we know consumes space on server RAM
 


Warm Regards:
Sitanshu

Please "Mark as Answer" if my post sort your problem
0
sbakshi
5/22/2008 4:46:30 AM
Reply:

Similar Artilces:

Caching, Caching,Caching,Caching,Caching Why nobody know???
I have posted this problem quite a few times but never got a decent answer and I have still not found a solution. Every time I have a gridview when the page is refreshed the data in the gridview does not refresh. You might say well and GridView.DataBind() to the pageload method but I think there is a performance problem if you bind your gridviews every time. For example I have a dropdownlist, a gridview and button and the gridview is supposed to refresh depending on the value in the dropdown when the button is pushed. if you click on the button the gridview data does not change unless y...

I can't get no cache, I can't get no cache. 'Cause I try and I try and I try and, I can't get no, I can't get no cache.
I have fiddled out for days tinkering with the setting in about:config trying to get FireFox 12 to use the disk cache. I have NOT found the trick. This One Trick Pony ain't doing it like it used to up until recently. Pray tell anyone, What information can I share that will point a knowledgeable person to aid me in getting FF to disk.cache? I have also tried restarting FF with add-ons disabled, (There were NOT too many to do this to, so it was quick and easy) Here is my stab at trying to convey the information that MIGHT govern matters Using about:cache Informatio...

Re: I can't get no cache, I can't get no cache. ' Cause I try and I try and I try and, I can't get no, I can't get no cache.
<div>please com e see me about htis<br /> <br /> ------- Original Message f= rom the Global Relay Archive -------<br /> From: Hp &lt;ferd@farkel.net&gt;= <br /> To: "support-firefox@lists.mozilla.org" &lt;support-firefox@lists.mo= zilla.org&gt;<br /> Sent: Sun, 27 May 2012 18:30:18 -0700<br /> Subject: I = can't get no cache, I can't get no cache. 'Cause I try and I try and I try = and, I can't get no, I can't get no cache.<br /> <br /></div> <pre class=3D"gr-maex-body-pre&qu...

To cache or not to cache ?
I am really confused here. What I have are two forms one is where I get metadata for a document and next page where the user uploads the file for that document. What I want is a link from upload page back to the metadata page with the fields still filled in (cached maybe ?) and a link that takes back to that page without cache...In other words..I want two links on upload page one that take users back to the metadata page with fields filled in from previous request and the other link which takes to metadata form with empty fields. I am not sure how to accomplish this. I tried using ca...

to cache or not to cache?
i have a toolbar at the top of all my web pages and I am not sure whether it is worth caching or not. this toolbar is in fact a search facility consisting of 4 dropdownlists. 3 of the DDL's are static and 1 is databound. i would like to make the whole toolbar into a user control and cache it. Q1. If one of the DDL's selected item has changed the user control must know not to load from the cache. is it possible to include this kind of logic to a cached user control? Q2. Is it worth caching my toolbar? Or should I just consider caching the 1 databound DDl instead? any help much apprec...

To Cache or Not To Cache?
Hello, I'd like the opinion of the community on this question. We've just completed a migration from Exchange 5.5 to GroupWise 7. Migration went well. Right now, everyone is using WebAccess but I am rolling out the GroupWise Windows client (with latest FTFs) along with an updated XP SP2 workstation image shortly, to the office people. They had been using Outlook with Exchange, no caching. We have 6 locations with office people. About 25 are local to the PO server. The other locations, ranging from 25 to 8 per location are connected to the PO server via a T-1 WAN lin...

Not getting any cache hits with database cache
Hello, I am hoping someone can give me some tips on getting our databases to use caches more efficiently. We use a SQL Anywhere database server on a Win NT server with 64 megs RAM. We assigned 32 megs for the server cache. The databases are being accessed by an application we have developed using PowerBuilder 5.002. When I have used the Performance Monitor within Sybase Central, it indicates that there are Cache Reads and Cache Writes, but no Cache Hits. We are in the midst of upgrading our SQL Anywhere from 5.501 to 5.502, but I haven't read anything that would indicate a cha...

.Net Caching Ughhhh (Micro-caching)
I'm designing an application where data is continuous and becomes dirty in a matter of seconds. The load is also high and therefore, to avoid straining the database server, i cache all data for a couple of seconds. That's fine. However, some data are HIGHLY VOLATILE and requires the most latest data...for these types of data, I use 1 second caching. I done benchmarks of 1-6 second caching and the benefits on a high load server is enormous. However there is a problem with this micro caching technique.....the problem is...some of the objects get destroyed as soon as it is pulled out. ...

Getting started with caching
I'm attempting to add some caching to my site. I've never done this before, and I'm confused by the books I've read and all the options that are available. Here's what I've done so far.I have run aspnet_regsql.exe with the -ed option to enable the database for SQL cache dependency, and I've run it with the -et option on several tables in this database.I've added the following lines to my web.config file:        <caching>            <sqlCacheDependency enabled="true"&g...

Caching Problem in IIS
i wrote a test code to check how caching works. everything works fine when running the page using visual web developer. but once i copy the page into IIS running on win 2003 server the caching works sometimes ..sometime the caching is not working and  the data directly comes from the database. the caching is done for 40 seconds, i check whether the data comes from the database or cache by writing a line using response.write in my code. my code  Dim griddata, cachestart         griddata = Cache("grid")  If Cache("grid...

page cached that should not be cached
Hi, Thanks for the support. I'm using ASP.NET 2 but my problem is that I have an asp.net web page called: extractimage.aspx that receive a query string parameter and returns an image, so I call it by: ~/inicio/extractimage.aspx?usu=25 I have a linkbutton in a grid with this link, so I refresh the Grid and the correct image should be shown. But when I change the image in other page and I try to refresh the Grid, the previous image is shown, not the new one. It seems the extractimage.aspx web page is cached and I do not want that, I would like the current image is always displayed, no...

how to clear out data cache, statement cache and procedure cache?
Hi there, does anyone know is there some commands to to clear out data cache, statement cache and procedure cache? (without recycle database server) And for both ASE 12.5 and ASE 15? we need to run some performance comparsion in ASE 12.5 and ASE 15. I'd make sure the data cache are similar and procedure/statement cache is clear (so cached query plan is not used) for each case. This all depends on the (very) specific version of ASE data cache: ------------ as of 15.0.3 - dbcc cachedataremove(dbid | dbname, objid | objname, partitionid | partitionname, indid | indexname)...

To Cache or Not to Cache...That is the Question
During the design phase of developing an ASP.NET application it is vital developers utilize the ASP.NET Cache feature.  A good “rule of thumb” when deciding when to use the caching feature is when data, pages, parts of pages are used more than once.  More specifically any data that is general in nature and does not change depending on specific user requests is a perfect scenario for caching.  This saves on time and overhead for collecting and creating reusable objects.  However, it is possible to use too much caching.  For example, on a 32-bit application process you...

Cache
Hello,could anyone point me to any resource/link/best practice explaining the use of the Sql Server cache used along with the Output cache?Thanks.VB .Net Coder - Apologize my C# nescienceBest Regards. http://beta.asp.net/QUICKSTART/aspnet/doc/caching/SQLInvalidation.aspx-BrockDevelopMentorhttp://staff.develop.com/ballen Hi Brock, If I use Output and SqlServer Cache, what happens? I mean, let's say I set a duration of 60 seconds for the Output Cache, and also I set the Sql Server Cache for a specific table in the same page. If nothing happens to the data of the aforementioned table,...

Web resources about - To cache or not to cache - asp.net.getting-started

Grande Cache - Wikipedia, the free encyclopedia
... 119.12250°W  / 53.87472; -119.12250 Coordinates : 53°52′29″N 119°07′21″W  /  53.87472°N 119.12250°W  / 53.87472; -119.12250 Grande Cache ...

Monitoring cache with Claspin - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Monitoring cache with Claspin geschrieben. Du kannst den vollständigen Text hier lesen.

Caché (@CacheStyle) on Twitter
Log in Sign up You are on Twitter Mobile because you are using an old version of Internet Explorer. Learn more here Caché @ CacheStyle Official ...

Digitas Cache for iPad on the iTunes App Store
Get Digitas Cache on the App Store. See screenshots and ratings, and read customer reviews.

Pizza Hut from W Lawton Cache Location - Flickr - Photo Sharing!
Easily one of the worst deliveries I've ever seen... On top of the mess of a delivery, the pizza itself was undercooked.

Turning Caches into Distributed Systems with mcrouter - Data@Scale - YouTube
Ryan McElroy, software engineer at Facebook, introduces "mcrouter," software that the company has developed for turning standalone caches into ...

Rocket launchers, grenades among cache of weapons found in Gippsland
Rocket launchers and hand grenades reportedly among 140 weapons found by police at a property in Gippsland.

Gun licence revoked after police find massive cache of weapons on Sunshine Coast
A Sunshine Coast man who had a cache of unregistered weapons will not get his gun licence back, after a tribunal ruled his &quot;Christian values&quot; ...

More on Apple’s A9X SoC: 147mm2@TSMC, 12 GPU Cores, No L3 Cache
... 1GB LPDDR2 Memory Bus Width 128-bit 64-bit 128-bit 128-bit Memory Bandwidth 51.2GB/sec 25.6GB/sec 25.6GB/sec 17.1GB/sec L2 Cache ...

How to clear app data and cache in Android 6.0 Marshmallow
Have you updated to Android 6.0 Marshmallow and have been left wondering how to clear app data and clear app cache? We've got you covered!

Resources last updated: 1/18/2016 6:04:59 AM