agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Make sure all static content is served from a CDN 
	and that only one CDN is used for all content
-----------------------------------------------------------------------------*/
Make sure all static content is served from a CDN
and that only one CDN is used for all content
Make sure all static content is served from a CDN and that only one CDN is used for all content
void CPagetestReporting::CheckCDN()
{
	staticCdnScore = -1;
	oneCdnScore = -1;
	DWORD count = 0;
	int total = 0;
	ATLTRACE(_T("[Pagetest] - CheckCDN\n"));
	count = 0;
	POSITION pos = events.GetHeadPosition();
	while( pos )
	{
		CTrackedEvent * e = events.GetNext(pos);
		if( e && e->type == CTrackedEvent::etWinInetRequest)
		{
      bool isStatic = false;
			CWinInetRequest * w = (CWinInetRequest *)e;
			CString mime = w->response.contentType;
			mime.MakeLower();
			CString exp = w->response.expires;
			exp.Trim();
			CString cache = w->response.cacheControl;
			cache.MakeLower();
			CString pragma = w->response.pragma;
			pragma.MakeLower();
			CString object = w->object;
			object.MakeLower();
			if( w->result == 200 &&
				w->fromNet &&
				exp != _T("0") && 
				exp != _T("-1") && 
				!(cache.Find(_T("no-store")) > -1) &&
				!(cache.Find(_T("no-cache")) > -1) &&
				!(pragma.Find(_T("no-cache")) > -1) &&
				!(mime.Find(_T("/html")) > -1)	&&
				!(mime.Find(_T("/xhtml")) > -1)	&&
				(	mime.Find(_T("shockwave-flash")) >= 0 || 
					object.Right(4) == _T(".swf") ||
					mime.Find(_T("text/")) >= 0 || 
					mime.Find(_T("javascript")) >= 0 || 
					mime.Find(_T("image/")) >= 0) )
			{
        isStatic = true;
      }
      bool is_cdn = IsCDN(w, w->cdnProvider);
      if (isStatic && !e->ignore) {
        if (is_cdn) {
			    w->staticCdnScore = 100;
        } else {
				  w->staticCdnScore = 0;
				  w->warning = true;
        }
				count++;
			  total += w->staticCdnScore;
      }
		}
	}
	if( count )
		staticCdnScore = total / count;
}
void CPagetestReporting :: CheckCDN ( ) { staticCdnScore = -1 ; oneCdnScore = -1 ; DWORD count = 0 ; int total = 0 ; ATLTRACE ( _T ( " \n " ) ) ; count = 0 ; POSITION pos = events . GetHeadPosition ( ) ; while ( pos ) { CTrackedEvent * e = events . GetNext ( pos ) ; if ( e && e -> type == CTrackedEvent :: etWinInetRequest ) { bool isStatic = false ; CWinInetRequest * w = ( CWinInetRequest * ) e ; CString mime = w -> response . contentType ; mime . MakeLower ( ) ; CString exp = w -> response . expires ; exp . Trim ( ) ; CString cache = w -> response . cacheControl ; cache . MakeLower ( ) ; CString pragma = w -> response . pragma ; pragma . MakeLower ( ) ; CString object = w -> object ; object . MakeLower ( ) ; if ( w -> result == 200 && w -> fromNet && exp != _T ( " " ) && exp != _T ( " " ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( pragma . Find ( _T ( " " ) ) > -1 ) && ! ( mime . Find ( _T ( " " ) ) > -1 ) && ! ( mime . Find ( _T ( " " ) ) > -1 ) && ( mime . Find ( _T ( " " ) ) >= 0 || object . Right ( 4 ) == _T ( " " ) || mime . Find ( _T ( " " ) ) >= 0 || mime . Find ( _T ( " " ) ) >= 0 || mime . Find ( _T ( " " ) ) >= 0 ) ) { isStatic = true ; } bool is_cdn = IsCDN ( w , w -> cdnProvider ) ; if ( isStatic && ! e -> ignore ) { if ( is_cdn ) { w -> staticCdnScore = 100 ; } else { w -> staticCdnScore = 0 ; w -> warning = true ; } count ++ ; total += w -> staticCdnScore ; } } } if ( count ) staticCdnScore = total / count ; }
Make sure all static content is served from a CDN
and that only one CDN is used for all content
Make sure all static content is served from a CDN and that only one CDN is used for all content
// average the CDN scores of all of the objects for the page
