Exemplo n.º 1
0
        private void Generator_Cache(HttpContext context, HttpRequest request, string key,UrlItem urlitem)
        {
            if (request.QueryString[GENERATOR_TAG] == null)
            {
                lock (mGenerator)
                {
                    if (mGenerator.ContainsKey(key))
                        return;

                    GetUrlItem item = new GetUrlItem();
                    item.Item = urlitem;
                    item.Cache = context.Cache;
                    item.URL = context.Request.Url.ToString();
                    item.Key = key;
                    if (request.QueryString.Count == 0)
                    {
                        item.URL += "?";
                    }
                    else
                    {
                        item.URL += "&";
                    }
                    item.URL += "_cache_generator=true";
                    item.Completed = Generator_Completed;
                    mGenerator.Add(key, key);
                    GetDespatch.Add(item);
                }
            }
        }
Exemplo n.º 2
0
        public UrlItem Match(string url)
        {
            UrlItem result = null;

            if (!mUrls.TryGetValue(url, out result))
            {
                Builder(url);
            }
            return(result);
        }
Exemplo n.º 3
0
 private void Cache_WithWeb(HttpContext context, HttpRequest request, string key, UrlItem urlitem)
 {
     PageCacheItem data = (PageCacheItem)context.Cache[key];
     if (data == null)
     {
         Generator_Cache(context, request, key,urlitem);
     }
     else
     {
         OutputCache(data, context);
     }
 }
Exemplo n.º 4
0
 public void LoadFile(string file)
 {
     XmlDocument doc = new XmlDocument();
     doc.Load(file);
     XmlNode root = doc["urls"];
     foreach (XmlNode url in root.ChildNodes)
     {
         UrlItem item = new UrlItem();
         item.UrlRegex = url.Attributes["match"].InnerText;
         item.Expiry = int.Parse(url.Attributes["expiry"].InnerText);
         mMatchs.Add(item);
     }
 }
Exemplo n.º 5
0
        public void LoadFile(string file)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(file);
            XmlNode root = doc["urls"];

            foreach (XmlNode url in root.ChildNodes)
            {
                UrlItem item = new UrlItem();
                item.UrlRegex = url.Attributes["match"].InnerText;
                item.Expiry   = int.Parse(url.Attributes["expiry"].InnerText);
                mMatchs.Add(item);
            }
        }
Exemplo n.º 6
0
        private void Application_BeginRequest(Object source, EventArgs e)
        {
            HttpApplication application = (HttpApplication)source;
            HttpContext     context     = application.Context;
            HttpRequest     request     = context.Request;

            if (request.RequestType == "GET")
            {
                LoadUrlMatch(request);
                UrlItem urlitem = mUrlMatch.Match(request.FilePath);
                if (urlitem != null)
                {
                    string key = getMd5Hash(context.Request.Url.ToString());
                    Cache_WithWeb(context, request, key, urlitem);
                }
            }
        }
Exemplo n.º 7
0
        private void Generator_Cache(HttpContext context, HttpRequest request, string key, UrlItem urlitem)
        {
            if (request.QueryString[GENERATOR_TAG] == null)
            {
                lock (mGenerator)
                {
                    if (mGenerator.ContainsKey(key))
                    {
                        return;
                    }

                    GetUrlItem item = new GetUrlItem();
                    item.Item  = urlitem;
                    item.Cache = context.Cache;
                    item.URL   = context.Request.Url.ToString();
                    item.Key   = key;
                    if (request.QueryString.Count == 0)
                    {
                        item.URL += "?";
                    }
                    else
                    {
                        item.URL += "&";
                    }
                    item.URL      += "_cache_generator=true";
                    item.Completed = Generator_Completed;
                    mGenerator.Add(key, key);
                    GetDespatch.Add(item);
                }
            }
        }
Exemplo n.º 8
0
        private void Cache_WithWeb(HttpContext context, HttpRequest request, string key, UrlItem urlitem)
        {
            PageCacheItem data = (PageCacheItem)context.Cache[key];

            if (data == null)
            {
                Generator_Cache(context, request, key, urlitem);
            }
            else
            {
                OutputCache(data, context);
            }
        }