Skip to content

banner ajax
The Complete Reference: Ajax

Examples: Browser Cache

Built in Cache Explorer

Prevent Caching:
Enable Caching:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chapter 6 : Networking Considerations - Built in Caching Explorer</title>
<link rel="stylesheet" href="" type="text/css" media="screen" />
<script src="" type="text/javascript">
<script type="text/javascript">
function prepareRequests(form)
    var url =  "";
    var prevent = form.prevent.options[form.prevent.selectedIndex].value;
    var enable = form.enable.options[form.enable.selectedIndex].value;
    var payload = "";
    if (prevent == "date")
        payload = "ts=" + (new Date()).getTime();
    else if (prevent == "response")
        payload = "headers=prevent";
    else if (enable == "response")
        payload = "headers=enable";
    /* define communication options */
      var options = { method: "GET",
              outputTarget : "responseOutput",
    if (prevent == "request")
        options.preventCache = true;
window.onload = function () 
 document.requestForm.requestButton.onclick = function () { prepareRequests(this.form); };
<div class="content">
<h1>Built in Cache Explorer</h1>
<form action="#" name="requestForm">
<table width="100%">
<tr class="row">
<td width="125">Prevent Caching:</td>
  <select name="prevent">
      <option value="none">None</option>
    <option value="response">Response Headers</option>
    <option value="request">Request Headers</option>
    <option value="date">Unique URL</option>
<tr class="row">
<td>Enable Caching: </td>
<td><select name="enable">
    <option value="none">None</option>
    <option value="response">Response Headers</option>
<br />
  <input type="button" name="requestButton" value="Send Request" />
<br />
<div id="response" class="results">
    <div id="responseOutput">&nbsp;</div>