Presently i have the following action to return files (images, PDF's, etc) from my DB:
//
// GET: /FileManager/GetFile/ID
[OutputCache(Duration = 600, VaryByParam = "ID")]
public ActionResult GetFile(int ID)
{
FileService svc = new FileService(new SqlFileRepository(base.ConnectionString));
KsisOnline.Data.File result = svc.GetFileByID(ID);
return File(result.Data, result.MimeType, result.UploadFileName);
}
I'm using the OutputCache
attribute but i dont know if i'm using it correctly or how to optimise it for this purpose.
As the code stands, i appear to get cache functionality in Firefox(3) but not IE(7). For some reason IE is requesting the image from the DB every time (which is killer bad obviously) and i dont know how to fix it. Sure IE doesn't support standards properly but maybe i'm still not following some preferred caching conventions. I'd really appreciate some help with this so i get minimal DB hits and caching support cross browser.
EDIT: To see the code above in action or to profile it yourself with browsers/tools, refer to this link.
Try use ServerAndClient location:
[OutputCache(Duration=600, VaryByParam="ID", Location=OutputCacheLocation.ServerAndClient)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With