caching

Ruby on Rails: Is there a way to find with ActiveRecord that will first try the cache and if it fails run a query?

Let's say that I'm looking for a specific item in a has_many association. Is there a way to find that won't rehit the database if what I'm requesting is already cached? Here's my situation (which is not working and does not do what I requested): class User has_many :friendships def some_function(buddy) f = friendships.detect{...

How to take advantage of browser caching of XAPS

I have a Silverlight Application that currently downloads XAPs on demand using Package.DownloadPackageAsync() from the System.ComponentModel.Composition.Packaging namespace. As far as I can tell this circumvents any sort of browser caching of XAPS that may take place. Does anyone know how to take advantage of browser caching using on d...

Caching functions instead of require_once in php

Hi guys, I've been using APC caching functions and it's been phenomenal. I was thinking, why not just cache all of my functions, and load them whenever I need to (kind of like frameworks actually). function Foo {echo 'bar';} $foo = Foo; apc_store('foo',$foo); And then whenever Foo is needed, I'd just use apc_fetch. Is that more effic...

C# Code Optimization, Profiling , Application Optimization

I m contributing to a project that s been developed for over a year and I jumped into it in lately. There are performance problems with the application. I m aware of several profiling tools, approaches for optimization such as find out the bottlenecks and optimize them. I m comfortable with algorithms, running times of iterations etc....

ASP.NET - Refreshing a posted page that isn't cached on IE

Lets say you have a page with headers that tell the browser not to cache. Also, this page has already been posted back to itself. Now you hit the refresh button and you click cancel on the IE modal box with the "previously submitted..." message. You get "Webpage has expired". This doesn't happen in FF or Chrome. Is there a way to pr...

What is the best way to store an ActiveRecord object in memcached?

There are currently two problems with storing ActiveRecord objects in memcached. The Undefined Class/Module problem (Google search). From what I've read up, this is still a bug that nobody has a real good solution for. The cache_fu plugin has probably the best solution for this, wrapping its retrieve call in a block that tries to catc...

How to prime cache and keep it updated

I'm planning on caching some information using ehcache. Normally, I would follow the pattern: if data in cache return from cache else lookup from source put into cache return data But for this data, I'd like it to always be in memory. I'd prefer to do: Populate cache while appserver starts up (I'm using JBoss) Have a "...

cache headers for dynamic css (generated via PHP)

My CSS file is acutally a PHP file which is served with content-type text/css so that I can use PHP variables in that file. style.php looks like this: <?php header('Content-Type: text/css'); $bgColor = '#000'; ?> body { background:<?php print $bgColor; ?>; } It works as expected, but I am a bit worried if the browser caches the dynam...

How to use Jquery Ajax Cache, is there a useful plugin for that and how can i test it?

I am using the jquery $.Ajax property for getting some data from database as json and manipulating dom with that. For example like this: $.ajax({ type: "POST", url: "TipsAndTricksService.asmx/postCommentForTT", data: "{'ttID':'" + ttID + "','text':'" + answerText + "','authorOfTT':'" + authorOfTT + "'}", contentType: "applicati...

How do you handle browser cache with login/logout?

To improve performances, I'd like to add a fairly long Cache-Control (up to 30 minutes) to each page since they do not change often. However, each page also displays the name of the user logged in (like this website). The problem is when the user logs in or logs out: the user name must change. How can I change the user name after each l...

How do I reduce number of redundant requests with mod_perl properly?

In a fairly big legacy project, I've refactored several hairy modules into Moose classes. Each of these modules requires database access to (lazy) fetch its attributes. Since those objects are used pretty heavily, I want to reduce the number of redundant requests, for example for unchanged data. Now, how do I do that properly? I've got ...

How to close the prefetch of cache in windows?

In a C/C++ program, how to close the prefetch of each core in the Windows system? ...

django: caching passwords for custom authentication

I am authenticating users in ldap, but this happens only once, when user is logging in. Afterwards I need to keep username and password, because before every ldap operation I need to make bind on ldap server before every operation. What is the safe way to cache this password (I can't store in the database or cookies) for as long as sessi...

Simple caching mechanism in ASP.NET

I had asked a question on how to implement real time updates in ASP.NET and received a very explanatory and a helpful answer from "jdk" at: http://stackoverflow.com/questions/2347771/how-to-implement-real-time-updates-in-asp-net I understand that memcached or .net caching application block can be used as the caching layer. Currently, I...

Is it a good idea to cache data from web services into a database?

Let's assume that Stackoverflow offers web services where you can retrieve all the questions asked by a specific user. A request to get all question from user A can result in the following json output: { { "question": "What is rest?", "date_created": "20/02/2010", "votes": 1, }, { "question":...

How to make Rails caches_page survive a capistrano deploy?

Is it possible to configure Rails so caches created with caches_page survive a Capistrano deploy? Ie, can I configure the cache to be saved into a shared directory rather than in the public directory? ...

hibernate query cache specify cache duration

below is how i do query cache getHibernateTemplate().setCacheQueries(true); List<IssSection> result = (List<IssSection>) getHibernateTemplate().findByCriteria(crit); getHibernateTemplate().setCacheQueries(false); may i know how to specify duration of maximum time to cache this method? let say i want to clear cache after 5 min...

Caching And Queing while caching is being populated?

whats the correct way to cache a object(DataSet) and then get it and when it expires repopulate it with out a major hiccup in the application... the application relies on this data to be there for read only purposes. ...

IIS App Pool And Caching

I have created a public List that is runs and is accessed from my a Web Application. private static List<x> _x; static readonly object lockObjx = new object(); public static void XCache() { if (_x != null) return; lock (lockObjx) { _x = GetFromDatabase(); }...

Using a second backend with Varnish 1.0.3-2 in case of 404 from first backend

Hi there, We used to have a caching proxy setup using a very early version of Varnish (0.5ish, I think) which used the 'restart' action to send requests to a second backend in the case of a 404 on the first. The new version of Varnish doesn't seem to support this - the 'restart' action no longer seems to be supported, and the 'req.rest...