Solved

Client Side Caching

Posted on 2007-03-28
10
232 Views
Last Modified: 2010-04-20
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.
0
Comment
Question by:James_T
  • 5
  • 3
  • 2
10 Comments
 
LVL 8

Accepted Solution

by:
thur6165 earned 250 total points
Comment Utility
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
 
LVL 29

Assisted Solution

by:rdivilbiss
rdivilbiss earned 250 total points
Comment Utility
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
 
LVL 1

Author Comment

by:James_T
Comment Utility
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
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
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
 
LVL 8

Expert Comment

by:thur6165
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
>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
 
LVL 1

Author Comment

by:James_T
Comment Utility
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
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
>>rd the function sendToLog you wrote, what language is that in?

JavaScript (AJAX) for the client side.

0
 
LVL 1

Author Comment

by:James_T
Comment Utility
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
 
LVL 29

Expert Comment

by:rdivilbiss
Comment Utility
I'm not familiar with ACT, sorry.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now