agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Check each static element to make sure it was cachable
-----------------------------------------------------------------------------*/
Check each static element to make sure it was cachable
Check each static element to make sure it was cachable
void CPagetestReporting::CheckCache()
{
	cacheScore = -1;
	int count = 0;
	int total = 0;
	ATLTRACE(_T("[Pagetest] - CheckCache\n"));
	POSITION pos = events.GetHeadPosition();
	while( pos )
	{
		CTrackedEvent * e = events.GetNext(pos);
		if( e && e->type == CTrackedEvent::etWinInetRequest && !e->ignore )
		{
			CWinInetRequest * w = (CWinInetRequest *)e;
			CString mime = w->response.contentType.Trim().MakeLower();
      bool expiration_set;
      int seconds_remaining;
      if (w->result == 200 && mime.Find(_T("/cache-manifest")) == -1 && 
          GetExpiresRemaining(w, expiration_set, seconds_remaining))
      {
        count++;
        w->cacheScore = 0;
        w->ttl = seconds_remaining;
        if( expiration_set ) 
        {
          if( seconds_remaining >= 604800 )
            w->cacheScore = 100;
          else if( seconds_remaining >= 3600 )
            w->cacheScore = 50;
        }
        total += w->cacheScore;
      }
    }
  }
	if( count )
		cacheScore = total / count;
}
void CPagetestReporting :: CheckCache ( ) { cacheScore = -1 ; int count = 0 ; int total = 0 ; ATLTRACE ( _T ( " \n " ) ) ; POSITION pos = events . GetHeadPosition ( ) ; while ( pos ) { CTrackedEvent * e = events . GetNext ( pos ) ; if ( e && e -> type == CTrackedEvent :: etWinInetRequest && ! e -> ignore ) { CWinInetRequest * w = ( CWinInetRequest * ) e ; CString mime = w -> response . contentType . Trim ( ) . MakeLower ( ) ; bool expiration_set ; int seconds_remaining ; if ( w -> result == 200 && mime . Find ( _T ( " " ) ) == -1 && GetExpiresRemaining ( w , expiration_set , seconds_remaining ) ) { count ++ ; w -> cacheScore = 0 ; w -> ttl = seconds_remaining ; if ( expiration_set ) { if ( seconds_remaining >= 604800 ) w -> cacheScore = 100 ; else if ( seconds_remaining >= 3600 ) w -> cacheScore = 50 ; } total += w -> cacheScore ; } } } if ( count ) cacheScore = total / count ; }
Check each static element to make sure it was cachable
Check each static element to make sure it was cachable
// If age more than 7 days give 100
 // else if more than hour, give 50
 // Add the score to the total.
 // average the Cache scores of all of the objects for the page
