Archive: February, 2009

2º Seminário de Tecnologias Móveis IT PRO & DEV

Posted on 9:30am 2/23/2009 by Bruno Silva in Events, Mobility

A segunda edição do evento da comunidade PocketPT.net para os Profissionais de tecnologias móveis e relacionadas, dá continuidade ao sucesso obtido pela primeira edição.
Este ano, de modo a oferecer um conjunto de conteúdos mais alargado, as duas tracks foram divididas em dois dias, sendo o primeiro dia reservado a programadores e o segundo a profissionais de TI.
Consegue-se assim uma maior riqueza e abrangência de conteúdos e intervenientes.

Mais um evento sobre Windows Mobile promovido pela comunidade PocketPT.NET. A julgar pelos a que já assisti irá valer bem a pena. Inscrições abertas. Mais informações no site oficial.

ASP.NET Output Cache - Cleaning all at once

Posted on 3:52pm 2/05/2009 by Bruno Silva in .NET, ASP.NET, Programming, Web

I’ve been using a feature of ASP.NET called Output Cache. It allows you to have server-side cache for your ASP.NET webpages. You can define several profiles and cache expiration rules. You can read more about it in a simple and short article at MSDN or in the full documentation also at MSDN.

A feature that I wasn’t able to find was cleaning all the cached data. You can remove cache for a specific page using HttpResponse.RemoveOutputCacheItem(”pagename”) but to remove all pages (which can have several cached versions each) you have to use some kind of workaround. You can use a Cache dependency relying in a item stored in HttpContext.Cache items collection, but for my particular scenario it wasn’t the right solution. Why?

If you have several front-end servers serving your website, you have independent cache systems, so when forcing a cache cleaning, you will force it only for the front-end serving your request. To solve this issue I’ve created a cache system relying on a file dependency. This way, when I change that file, all the front-end servers will clean their cache. I’ve included a CacheManager class that has the usual Add method, that automatically add the file dependency to cached data ( usually using Response.Cache.Add) and not only output cache.

Download source code and have fun exploring it.

© Bruno Silva | Powered by Wordpress