Fossil

Check-in [cfb716fb]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:More administrative functions related to the Web Cache are now available on the /cachestat page.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cfb716fb83c0e1c3797a7af0d94a8967212596ec3856de6d95d8d555f00e5b9e
User & Date: drh 2025-04-09 12:25:43.704
Context
2025-04-09
13:07
Further improvements to the /cachestat page. ... (check-in: 3af3ffdf user: drh tags: trunk)
12:25
More administrative functions related to the Web Cache are now available on the /cachestat page. ... (check-in: cfb716fb user: drh tags: trunk)
11:23
Add the ability for an admin to create a web-cache from the web interface. ... (check-in: 7de57f40 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/cache.c.
416
417
418
419
420
421
422





423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449

450
451
452
453
454

455










456
457


458

459
460
461
462
463
464
465
    @ <form method="post">
    login_insert_csrf_secret();
    @ The web-page cache is disabled for this repository
    @ <input type="submit" name="init" value="Enable">
    @ </form>
  }else{
    char *zDbName = cacheName();





    cache_register_sizename(db);
    pStmt = cacheStmt(db,
         "SELECT key, sz, nRef, datetime(tm,'unixepoch')"
         "  FROM cache"
         " ORDER BY (tm + 3600*min(nRef,48)) DESC"
    );
    if( pStmt ){
      @ <ol>
      while( sqlite3_step(pStmt)==SQLITE_ROW ){
        const unsigned char *zName = sqlite3_column_text(pStmt,0);
        char *zHash = cache_hash_of_key((const char*)zName);
        @ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br>
        @ size: %,lld(sqlite3_column_int64(pStmt,1))
        @ hit-count: %d(sqlite3_column_int(pStmt,2))
        @ last-access: %s(sqlite3_column_text(pStmt,3)) \
        if( zHash ){
          @ %z(href("%R/timeline?c=%S",zHash))check-in</a>\
          fossil_free(zHash);
        }
        @ </p></li>

      }
      sqlite3_finalize(pStmt);
      @ </ol>
    }
    zDbName = cacheName();
    bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE));

    @ <p>
    @ cache-file name: %h(zDbName)<br>
    @ cache-file size: %s(zBuf)<br>
    @ max-cache-entry: %d(db_get_int("max-cache-entry",10))
    @ </p>

    @ <p>










    @ Use the "<a href="%R/help?cmd=cache">fossil cache</a>" command
    @ on the command-line to create and configure the web-cache.


    @ </p>

    fossil_free(zDbName);
    sqlite3_close(db);
  }
  style_finish_page();
}

/*







>
>
>
>
>




















|






>

<
<
<

>

>
>
>
>
>
>
>
>
>
>
|
|
>
>
|
>







416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
    @ <form method="post">
    login_insert_csrf_secret();
    @ The web-page cache is disabled for this repository
    @ <input type="submit" name="init" value="Enable">
    @ </form>
  }else{
    char *zDbName = cacheName();
    int nEntry = 0;
    int mxEntry = 0;
    if( P("clearcache")!=0 && cgi_csrf_safe(2) ){
      sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0);
    }
    cache_register_sizename(db);
    pStmt = cacheStmt(db,
         "SELECT key, sz, nRef, datetime(tm,'unixepoch')"
         "  FROM cache"
         " ORDER BY (tm + 3600*min(nRef,48)) DESC"
    );
    if( pStmt ){
      @ <ol>
      while( sqlite3_step(pStmt)==SQLITE_ROW ){
        const unsigned char *zName = sqlite3_column_text(pStmt,0);
        char *zHash = cache_hash_of_key((const char*)zName);
        @ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br>
        @ size: %,lld(sqlite3_column_int64(pStmt,1))
        @ hit-count: %d(sqlite3_column_int(pStmt,2))
        @ last-access: %s(sqlite3_column_text(pStmt,3)) \
        if( zHash ){
          @ %z(href("%R/timeline?c=%S",zHash))check-in</a>\
          fossil_free(zHash);
        }
        @ </p></li>
        nEntry++;
      }
      sqlite3_finalize(pStmt);
      @ </ol>
    }
    zDbName = cacheName();
    bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName, ExtFILE));
    mxEntry = db_get_int("max-cache-entry",10);
    @ <p>



    @ </p>
    @ <h2>About The Web-Cache</h2>
    @ <p>
    @ The web-cache is a separate database file that holds cached copies
    @ tarballs, ZIP archives, and other pages that are expensive to compute
    @ and are likely to be reused.
    @ <form method="post">
    @ <ul>
    @ <li> Filename of the cache database: <b>%h(zDbName)</b>
    @ <li> Size of the cache database: %s(zBuf)
    @ <li> Maximum number of entries: %d(mxEntry);
    @ <li> Number of slots used: %d(nEntry)
    @ <li> Change the max-cache-entry setting on the
    @ <a href="%R/setup_settings">Settings</a> page to adjust the
    @ maximum number of entries in the cache.
    @ <li><input type="submit" name="clear" value="Clear the cache">
    @ <li> Disable the cache by manually deleting the cache database file.
    @ </ul>
    @ </form>
    fossil_free(zDbName);
    sqlite3_close(db);
  }
  style_finish_page();
}

/*