|
| ||||
The AvantGo sync server works very much like any other proxy server. If you are not familiar with proxy servers, that is OK. Read on.
HTTP headersWhen a web server sends a page, whether to an ordinary browser, or the AvantGo sync server, it first sends a group of HTTP headers that look something like this:
The Cache-Control header and the max-age directiveMost of this is of little importance right now (although some of it is interesting), except for that one line that reads Note: As you will see, there are other ways to control caching, such as setting up an Suppose that the AvantGo sync server is grabbing a page from your channel with the above headers. It would notice the Note: Technically, we add on a few seconds depending on how long it took us to retrieve the document, but this is close enough for the purposes of instruction. Figure 5-7 AvantGo sync server stores information about cached pages
Calculating a page's ageFor the purposes of determining when a web page is "born", we look at the time we first access a document; not the document's Suppose that later, a different user requests that same document from your channel. The AvantGo sync server knows it has that page locally on its hard drive. The first thing it will do is calculate the page's age. The local time is 19:40:17 GMT, and your page was "born" on 17:28:02, so the page's age is 2:12:15, or 7935 seconds old. Figure 5-8 Cached page sent when max-age not exceeded
Determining if the page is still "fresh"The AvantGo sync server compares this value to the Note: Actually, we do a second level of caching here. The client on the mobile device also keeps track of the document's age and its Suppose a few more hours go by, and once again, somebody requests this page from your channel. The local time is 22:36:44. Now, that page is 5:08:42, or 18522 seconds old. 18522 is greater then 18000, so the page is considered stale. Determining if a newer page is availableAt this point, we have to go out on the Internet and see if there is a newer page available on your server. We do something rather clever where we ask if the page has been modified since the If the page has not been modified, the server on the Internet will tell us that the page has not changed. This comes in the form of a Note: Not all web servers add a Figure 5-9 Cached page sent when source page has not change
If the page on the Internet has been updated, then we go out and grab the newer, fresher version of the page, note the time, and then use this newer page on our cache. Figure 5-10 Outdated cached page is updated from source page
What about those desktop browser caches?Is this the same thing as the local hard-drive cache that Netscape or IE uses? No. The cache that you have on your hard drive is similar to the client cache that is stored on the mobile device. But they both function differently than the shared cache that is used on the AvantGo sync server. Seeing the HTTP headers for a pageHow do I see those HTTP headers for my web page? The easiest way is to telnet to your web server using port 80. So, you could type Then enter:
You should get the HTTP headers for that page, followed by the HTML, and then the server will disconnect. It is probably worth saving the session to a log file or having a big buffer, so you can see the headers at the beginning of the file. | ||||
|
