public void Get(HttpContext context) { ChachedRessource res = _cache.GetRessouce(_rootPath + context.Request.Path.Replace('/', '\\')); if (res != null) { context.Response.Payload.WriteBytes(res.Ressource); context.Response.Status = HttpStatus.OK; } else { context.Response.Status = HttpStatus.NotFound; } }
public ChachedRessource GetRessouce(string path) { if (HasRessource(path)) { try { ChachedRessource res = _cache[path]; if (res.CachedDate != File.GetLastWriteTimeUtc(path)) { res.Ressource = File.ReadAllBytes(path); res.CachedDate = File.GetLastWriteTimeUtc(path); } return(res); } catch (Exception e) { return(null); } } else { try { ChachedRessource res = new ChachedRessource(); res.CachedDate = File.GetLastWriteTimeUtc(path); res.Ressource = File.ReadAllBytes(path); res.Path = path; _cache.Add(path, res); return(res); } catch (Exception e) { return(null); } } }