Exemplo n.º 1
0
        private void Start(Object sender, EventArgs e)
        {
            if (debug) app.Response.Write("Starting...<br/>");

            SetParams();

            if (IsCachable())
            {
                if (debug) app.Response.Write("Looking for=>" + cachedUrl + "<br/>");
                if (debug) app.Response.Write("Mime/Type=>" + app.Response.ContentType + "<br/>");
                //if (debug) app.Response.Write("Extension=>" + extension + "<br/>");

                if (File.Exists(app.Server.MapPath(cachedUrl)))
                {
                    if (debug) app.Response.Write("Found cache=>" + hashedPath + " - " + pathQuery + " - " + app.Request.Url.Query + " - " + cachedUrl + " - " + app.Response.StatusCode + "<br/>");
                    //app.Context.RewritePath(cachedUrl,false);
                    app.Server.Transfer(cachedUrl);

                }
                else
                {
                    StreamWatcher watcher = new StreamWatcher(app.Response.Filter);
                    app.Context.Items["StaticCacheModule_watcher"] = watcher;
                    app.Response.Filter = watcher;
                }
            }
            else
            {
                if (debug) app.Response.Write("Not cacheable<br/>");
            }
        }
Exemplo n.º 2
0
 private void SetWatcher()
 {
     _watcher = new StreamWatcher( _app.Response.Filter );
     _app.Response.Filter = _watcher;
 }