Client Side Caching

I'm carrying out an investigation to see how the performance of a server side and client side cahed web application differs.

To capture the reponse time of a system using server side caching, i'm going to use performance counters on the web server.

Does anyone know how I can capture the response time of the application when its cached on the client?

Thanks.
LVL 1
James_TAsked:
Who is Participating?
 
thur6165Connect With a Mentor Commented:
It sounds like you want to get the response time from the users perspective in each case.  So whether or not if it is cached on the server or the client, how long does it take.  Not sure if the performance counter will get you what you want , but you can use a java script to get the amount of time.

http://javascript.internet.com/text-effects/loading-time-indicator.html
http://www.hashemian.com/tools/page-load-time.htm
0
 
rdivilbissConnect With a Mentor Commented:
thur6165, those are okay but to be useful you'll want to collect that information server side, so...

You need another server side page to accept page name and load time,

say log.php?p=myTestPage.php&t=0.17

And a way to send that information back to the log page,

maybe:

var xmlhttp;

function sendToLog(pTime) {
        var pURL = "/path/to/log.php?p=" + document.location.href + '&t=' +pTime
        //create the Cross-browser XMLHttpRequest object
        if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
               xmlhttp=new XMLHttpRequest();
              if (xmlhttp.overrideMimeType) {
                     xmlhttp.overrideMimeType('text/xml');
              }      
              xmlhttp.onreadystatechange=function { null };
              xmlhttp.open("GET", pURL, true);
              xmlhttp.send(null);
       } else if (window.ActiveXObject) { //IE
              xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
              if (xmlhttp) {
                     xmlhttp.onreadystatechange= function { null };
                     xmlhttp.open('GET', pURL, true);
                     xmlhttp.send();
              }
       }
  }

And really, if it is a PHP, ASP, JSP etc...it would be more accurate to do the timer with the server side script, as there will be some latency when the page loads before the JavaScript timer begins.
0
 
James_TAuthor Commented:
Well the application is developed in asp.net.

The investigation needs to as rigorous and scientifically credible as possible.

rd when you say the following:

And really, if it is a PHP, ASP, JSP etc...it would be more accurate to do the timer with the server side script, as there will be some latency when the page loads before the JavaScript timer begins.

Surely this wouldnt work if it is cached client side?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
rdivilbissCommented:
The request first goes to the server, therefore from the time you receive the request at the server until the client fires the XMLHTTP request is the total time.

Here is my browser retrieving Google's home page:

http://www.google.com/

GET / HTTP/1.1    <------------ first thing is request to Google for content.
Host: www.google.com
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cache-Control: max-age=0

HTTP/1.x 200 OK    <------------------ the response from Google
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip
Server: GWS/2.1
Content-Length: 2033
Date: Thu, 29 Mar 2007 00:20:04 GMT
----------------------------------------------------------
http://www.google.com/intl/en_ALL/images/logo.gif

GET /intl/en_ALL/images/logo.gif HTTP/1.1   <------ my browser requests the logo
Host: www.google.com
Accept-Encoding: gzip,deflate
Keep-Alive: 300
Connection: keep-alive
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified  <------------- Google responds the logo has not changed
Server: GWS/2.1
Content-Length: 0  <----------- Google sends nothing my browser fetches it from cache
Content-Type: text/html
Date: Thu, 29 Mar 2007 00:20:04 GMT
----------------------------------------------------------
http://www.google.com/images/x2.gif  <------- My browser requests another image

GET /images/x2.gif HTTP/1.1
Host: www.google.com
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.google.com/
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified  <--------- Google says not modified
Server: GWS/2.1
Content-Length: 0     <--------- nothing sent, I get it from cache
Content-Type: text/html
Date: Thu, 29 Mar 2007 00:20:05 GMT
----------------------------------------------------------
http://www.google.com/images/nav_logo2.png  <--- Yet another request

GET /images/nav_logo2.png HTTP/1.1
Host: www.google.com
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.google.com/
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified  <----- not modified, get from cache
Server: GWS/2.1
Content-Length: 0
Content-Type: text/html
Date: Thu, 29 Mar 2007 00:20:05 GMT
----------------------------------------------------------


So, If I start the timer at the beginning, until the call back to my log.aspx page, I get the true time to load, which also considers client side cache.

If I only start the timer after all the headers are sent and enough of the page loads to render the JavaScript, I'm missing possibly a significant amount of time, depending on what content is loaded before I retrieve from client cache.

In most cases, we are hopefully talking about milliseconds, but if you want scientific accuracy you better start at the beginning of the request headers.

You also need a large number of measurements....hundreds or thousands.

The time to send the call back to the log.aspx page will be negligible and averaged into all of the calls.  If you only count client side and don't send the results back, how will you get your measurements?



0
 
thur6165Commented:
The client side would have to be just the javascript.  The java script starts timing as soon as the page starts getting parsed by the browser.

I beleive the server side script is getting the amount of time it takes for the server to create the page.  So maybe your solution there is to add the time of the javascript and the server side script.

rdivilbiss - correct me if i'm wrong on this.  what is the php script timing?

0
 
rdivilbissCommented:
>what is the php script timing?

In this case it would have to be aspx, but it wouldn't matter as the time sent by the client back to the aspx page would be constant so any response delay on the aspx page receiving the data would not be counted.

>The java script starts timing as soon as the page starts getting parsed by the browser.

I don't agree that the JavaScript starts as soon as the page starts getting parsed.  It has to render all the headers and at least load the script block before that occurs.  Since the question is page load time, which starts at the request, not when the page has rendered sufficiently to begin to execute JavaScript.  

So when the page has finished loading, we send the time back to the server via AJAX to an aspx receiver.  The time it takes for that to process isn't counted so we are only getting the time from the request until the page has rendered. If the aspx receiver took ten minutes to process, that wouldn't matter.

Now I'm not going to say there should be a significant amount of time between the initial request and the beginning of the JavaScript timer, but depending on the page layout and the server, it could be.  It should be counted.

Also, client time can be different from Server time, but that's easily accounted for by using GMT time on both ends.  Then you simply have end-begin = actual rendering time.

0
 
James_TAuthor Commented:
So to sum up, if I put the Javascript in both the server side cached and client side cached versions of the application, and pass the results across to an aspx page to store the results, this would be an accurate experiment?

rd the function sendToLog you wrote, what language is that in?  

Thanks for both of your help.
0
 
rdivilbissCommented:
>>rd the function sendToLog you wrote, what language is that in?

JavaScript (AJAX) for the client side.

0
 
James_TAuthor Commented:
Right i've got that working.

To test the affect of both tyoes of caching i am going to load test the system with varying numbers of using using Microsoft Application Center Test (ACT).

The way ACT works is by generating a script consisting of the GET and POST requests, when I run this script, would it bypass the client side caching and go to the server or would it get the page from the client cache?
0
 
rdivilbissCommented:
I'm not familiar with ACT, sorry.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.