Пример #1
0
    public void ProcessRequest(HttpContext context)
    {
        const string key   = "Scripts";
        Cache        cache = context.Cache;

        DateTime  lastWriteTime = GetLastWriteTime();
        DatedText scripts       = null;

        lock (ScriptsLock)
        {
            if (cache[key] != null)
            {
                scripts = (DatedText)cache[key];

                if (scripts.Date < lastWriteTime)
                {
                    scripts = null;
                }
            }

            if (scripts == null)
            {
                scripts = new DatedText(lastWriteTime, GetMinifiedScripts());
                cache.Insert(key, scripts, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
            }
        }

        context.Response.ContentType = "text/javascript";
        context.Response.Write(scripts.Text);
    }
Пример #2
0
  public void ProcessRequest(HttpContext context)
  {
    const string key = "Stylesheets";
    Cache cache = context.Cache;

    DateTime lastWriteTime = GetLastWriteTime();
    DatedText stylesheets = null;

    lock (StylesheetsLock)
    {
      if (cache[key] != null)
      {
        stylesheets = (DatedText)cache[key];

        if (stylesheets.Date < lastWriteTime)
        {
          stylesheets = null;
        }
      }

      if (stylesheets == null)
      {
        stylesheets = new DatedText(lastWriteTime, GetMinifiedStylesheets());
        cache.Insert(key, stylesheets, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
      }
    }

    context.Response.ContentType = "text/css";
    context.Response.Write(stylesheets.Text);
  }