patch for IMS support

From: Jaeyeon Jung <jyjung@dont-contact.us>
Date: Sat, 24 Aug 1996 21:37:18 -0900 (GMT)

        I added following two features for supporting IMS (If-Modified-Since)

        to squid1.0.beta17, with Nordstrom's help (He provided basic ideas)

        1.Make IMS hierarchical.
        
         Current version of Squid supports IMS GET retrievals, but not
         
         through any neighbor caches. Therefore, when the object is not

         in the cache, Squid retrieves it directly from an original server.

         So, I make IMS GET hierarchical, not so as to waste bandwidth.

                 * if the object (which is not in a squid cache, but in a local
                 
                   cache) is requested with IMS GET, Squid forwards that request
                   
                  to its one of parents with IMS header.

        2.Return the appropriate headers with the 304 response.

                * When a requested object with IMS request is in the Squid

                  cache and not modified since If-Modified-Since date ,

                  Squid sends just "HTTP/1.0 304 Not Modified " without any

                  headers, unlike usual Servers. ( They reply several
                  
                  fields of headers - Expires, Date, Content-Length..- as well

                  as 304 Not Modified).

        In addition, I propose the following thing.

        * Instead of throwing away expired objects, How about sending IMS

           GET to the original server when it is requested?

 - I applied this patch to my system (cache.kaist.ac.kr), and now gather

   the data about how much bandwith it could save using this mechanism.

   (IMS hierarchical).

*** /squid-1.0.beta17-jyjung/icp.c Sat Aug 24 20:01:05 1996
--- /squid-1.0.beta17-src/src/icp.c Mon Jun 10 11:37:32 1996
***************
*** 78,86 ****
  static void icpHandleStore _PARAMS((int, StoreEntry *, icpStateData *));
  static void icpHandleStoreComplete _PARAMS((int, char *, int, int, void *icpState));
  static void icpHandleStoreIMS _PARAMS((int, StoreEntry *, icpStateData *));
- static void icpConstruct304reply _PARAMS((char *,struct _http_reply *));
  static void icpHandleIMSComplete _PARAMS((int, char *, int, int, void *icpState));
  static int icpProcessHIT _PARAMS((int, icpStateData *));
  static int icpProcessIMS _PARAMS((int, icpStateData *));
--- 78,83 ----
***************
*** 202,216 ****
      request_t *req = icpState->request;
      method_t method = req->method;
      wordlist *p = NULL;
! /*
! if (BIT_TEST(icpState->flags, REQ_IMS))
          return 0;
- */
- /* when user hit reload */
- if (BIT_TEST(icpState->flags, REQ_IMS)&&BIT_TEST(icpState->flags, REQ_NOCACHE))
- return 0;
      if (BIT_TEST(icpState->flags, REQ_AUTH))
          return 0;
      if (method != METHOD_GET)
--- 198,205 ----
      request_t *req = icpState->request;
      method_t method = req->method;
      wordlist *p = NULL;
! if (BIT_TEST(icpState->flags, REQ_IMS))
          return 0;
      if (BIT_TEST(icpState->flags, REQ_AUTH))
          return 0;
      if (method != METHOD_GET)
***************
*** 441,450 ****
      int IMS_length;
      time_t date;
      int length;
- char reply[8191];
  
      if (max_len <= 0) {
          debug(12, 1, "icpGetHeadersForIMS: To much headers '%s'\n",
--- 430,435 ----
***************
*** 505,514 ****
      if (IMS > date || (IMS == date && (IMS_length < 0 || IMS_length == length))) {
          /* The object is not modified */
          debug(12, 4, "icpGetHeadersForIMS: Not modified '%s'\n", entry->url);
- icpConstruct304reply(reply,mem->reply);
          comm_write(fd,
! reply,
! strlen(reply),
              30,
              icpHandleIMSComplete,
              icpState);
--- 490,498 ----
      if (IMS > date || (IMS == date && (IMS_length < 0 || IMS_length == length))) {
          /* The object is not modified */
          debug(12, 4, "icpGetHeadersForIMS: Not modified '%s'\n", entry->url);
          comm_write(fd,
! NotModified,
! strlen(NotModified),
              30,
              icpHandleIMSComplete,
              icpState);
***************
*** 515,567 ****
          return COMM_OK;
      } else {
          debug(12, 4, "icpGetHeadersForIMS: We have newer '%s'\n", entry->url);
          /* We have a newer object */
          return icpProcessHIT(fd, icpState);
      }
  }
- static void icpConstruct304reply(reply,source)
- char *reply;
- struct _http_reply *source;
- {
- char content_type[256];
- char content_length[256];
- char date[256];
- char expires[256];
- char last_modified[256];
-
- strcpy (reply, NotModified);
-
-
-
- if(strlen(source->date)>0) {
- sprintf(date,"Date: %s\n",source->date);
- strcat(reply, date);
- }
- if(strlen(source->content_type)>0) {
- sprintf(content_type,"Content-type: %s\n",source->content_type);
- strcat(reply, content_type);
- }
- if(source->content_length) {
- sprintf(content_length,"Content-length: %d\n",source->content_length);
- strcat(reply, content_length);
- }
- if(strlen(source->expires)>0) {
- sprintf(expires,"Expires: %s\n",source->expires);
- strcat(reply, expires);
- }
- if(strlen(source->last_modified)>0) {
- sprintf(last_modified,"Last-modified: %s\n",source->last_modified);
- strcat(reply, last_modified);
- }
-
- sprintf(reply,"%s\r\n",reply);
- }
  
  static void icpHandleStoreIMS(fd, entry, icpState)
       int fd;
--- 499,508 ----

*** /squid-1.0.beta17-jyjung/proto.c Sat Aug 24 20:02:46 1996
--- /squid-1.0.beta17-src/src/proto.c Mon Jun 10 11:37:33 1996
***************
*** 126,142 ****
          /* protoDataFree(protoData); */
          return 0;
      }
- if ((e = protoData->parent) &&
- (BIT_TEST(entry->flag, IFMODSINCE))) {
- /* It makes IMS hierarchical */
- hierarchy_log_append(protoData->url, HIER_SINGLE_PARENT, 0, e->host);
- mem->hierarchy_code = HIER_SINGLE_PARENT;
- getFromCache(protoData->fd, entry, e, req);
- /* protoDataFree(protoData); */
- return 0;
- }
      if (protoData->n_edges == 0 && protoData->direct_fetch == DIRECT_NO) {
          hierarchy_log_append(protoData->url, HIER_NO_DIRECT_FAIL, 0, req->host);
          mem->hierarchy_code = HIER_NO_DIRECT_FAIL;
--- 126,131 ----
***************
*** 223,231 ****
      protoData->inside_firewall = matchInsideFirewall(request->host);
      protoData->query_neighbors = BIT_TEST(entry->flag, HIERARCHICAL);
      protoData->single_parent = getSingleParent(request, &n);
- protoData->parent = getFirstUpParent(request);
      protoData->n_edges = n;
  
      debug(17, 2, "protoDispatch: inside_firewall = %d (%s)\n",
--- 212,217 ----
***************
*** 271,283 ****
          protoData->direct_fetch = DIRECT_MAYBE;
          BIT_RESET(protoData->entry->flag, IP_LOOKUP_PENDING);
          protoDispatchDNSHandle(fd, (struct hostent *) NULL, protoData);
- } else if (protoData->parent && BIT_TEST(entry->flag, IFMODSINCE)) {
- /* will fetch from a parent */
- protoData->direct_fetch = DIRECT_MAYBE;
- BIT_RESET(protoData->entry->flag, IP_LOOKUP_PENDING);
- protoDispatchDNSHandle(fd, (struct hostent *) NULL, protoData);
      } else {
          /* will use ping resolution */
          protoData->source_ping = getSourcePing();
--- 257,262 ----
*** /squid-1.0.beta17-jyjung/proto.h Sat Aug 24 19:55:54 1996
--- /squid-1.0.beta17-src/src/proto.h Fri Jun 7 07:10:23 1996
***************
*** 180,186 ****
      int query_neighbors;
      int n_edges;
      struct _edge *single_parent;
- struct _edge *parent;
  } protodispatch_data;
  
  extern int proto_cachable _PARAMS((char *url, int method));
--- 180,185 ----

*** /squid-1.0.beta17-jyjung/store.c Sat Aug 24 19:55:54 1996
--- /squid-1.0.beta17-src/src/store.c Wed Jun 12 08:33:45 1996
***************
*** 626,637 ****
          BIT_SET(e->flag, HIERARCHICAL);
      else
          BIT_RESET(e->flag, HIERARCHICAL);
- if (BIT_TEST(flags, REQ_IMS))
- BIT_SET(e->flag,IFMODSINCE );
- else
- BIT_RESET(e->flag,IFMODSINCE );
      if (neighbors_do_private_keys || !BIT_TEST(flags, REQ_HIERARCHICAL))
          storeSetPrivateKey(e);
      else
--- 626,631 ----

*** /squid-1.0.beta17-jyjung/store.h Sat Aug 24 20:01:45 1996
--- /squid-1.0.beta17-src/src/store.h Wed Jun 12 08:33:46 1996
***************
*** 18,26 ****
   * KEY_CHANGE If the key for this URL has been changed
   */
  
- #define IFMODSINCE (1<<14)
  #define HIERARCHICAL (1<<13) /* can we query neighbors? */
  #define KEY_PRIVATE (1<<12) /* is the key currently private? */
  #define ENTRY_DISPATCHED (1<<11)
--- 18,23 ----
         
Received on Sat Aug 24 1996 - 05:47:24 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:32:51 MST