0

Pls clarify which one of the following is correct?
In the user's manual P.27, it is stated that:

// note: no starting ‘/’ in the virtual path
static char path[] = ”tools/counter.html”; // a ‘virtual’ path int expire = 0; // 0:never

But in the header file of gwan.h, it is stated that:

//create/update a cache entry ('file' MUST be imaginary if 'buf' is not NULL)
// cacheadd(argv, "/tool/counter", buf, 1024, ".json", 200, 60); // expire:60sec
// cacheadd(argv, "/archives/doc_1.pdf", 0, 0, 0, 200, 0); // never expire
// ('file' MUST exist if 'buf' is NULL)

Which one is correct, with starting "/" or not?

Gil
  • 3,279
  • 1
  • 15
  • 25
k.k. lou
  • 1,805
  • 2
  • 13
  • 16

1 Answers1

0

Thank you for pointing at this discrepancy between the manual and the (older) header.

The proper notation is without a starting slash, as shown in the cache.c example of the G-WAN distribution:

   static char szpath[] = "cache1.html";
   int expire = 15;
   if(!cacheadd(argv, szpath, reply->ptr, reply->len, ".html", 200, expire))
   {
      printf("* error: could not add cache entry #1\n");
      return 503;
   }   

The comment in the header file's comments will be updated. When in doubt, trying is probably the best way to check what works.

Gil
  • 3,279
  • 1
  • 15
  • 25