Fossil

Check-in [2588d447]
Login

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

Overview
Comment:Optimizations to the ETag implementation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | etags-cache-control
Files: files | file ages | folders
SHA3-256:2588d447839e1b44ef1408e0fd556a8bfefbfee8710abb8d8ecd52f81db9f34d
User & Date: drh 2018-02-24 03:47:49
Context
2018-02-24
20:14
Redesign the ETags mechanism to be simpler and safer. check-in: ae660cd6 user: drh tags: etags-cache-control
03:49
Add support for the ETag: and If-None-Match: headers for improved cache control. Currently this only works for /uv but the mechanism is reasonably general and can be extended to other pages. check-in: 787896c5 user: drh tags: etags
03:47
Optimizations to the ETag implementation. check-in: 2588d447 user: drh tags: etags-cache-control
03:38
ETags now working for the /uv page. check-in: 5b84cab0 user: drh tags: etags-cache-control
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/etag.c.

127
128
129
130
131
132
133

134
135
136
137
138
139
140
...
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
**
** After each call to these routines, the HTTP_IF_NONE_MATCH cookie
** is checked, and if it contains a compatible ETag, then a
** 304 Not Modified return is generated and execution aborts.  This
** routine does not return if the 304 is generated.
*/
void etag_require(int code){

  mEtag |= code;
  etag_check();
}
void etag_require_hash(const char *zHash){
  if( zHash ){
    zEHash = zHash;
    mEtag = ETAG_HASH;
................................................................................
** fossil binary is sufficient to invalidate all prior caches.
**
** The other elements are only present if the appropriate mask bits
** appear in the first character.
*/
char *etag_generate(int m){
  Blob x = BLOB_INITIALIZER;
  int mtime;
  if( m<0 ) m = mEtag;
  if( m & ETAG_DYNAMIC ) return 0;
  mtime = file_mtime(g.nameOfExe, ExtFILE);
  blob_appendf(&x,"%d%x", m, mtime);
  if( m & ETAG_HASH ){
    blob_appendf(&x, "/%s", zEHash);
  }else if( m & ETAG_DATA ){
    int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom");
    blob_appendf(&x, "/%x", iKey);
  }else if( m & ETAG_CONFIG ){







>







 







|


|







127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
**
** After each call to these routines, the HTTP_IF_NONE_MATCH cookie
** is checked, and if it contains a compatible ETag, then a
** 304 Not Modified return is generated and execution aborts.  This
** routine does not return if the 304 is generated.
*/
void etag_require(int code){
  if( (mEtag & code)==code ) return;
  mEtag |= code;
  etag_check();
}
void etag_require_hash(const char *zHash){
  if( zHash ){
    zEHash = zHash;
    mEtag = ETAG_HASH;
................................................................................
** fossil binary is sufficient to invalidate all prior caches.
**
** The other elements are only present if the appropriate mask bits
** appear in the first character.
*/
char *etag_generate(int m){
  Blob x = BLOB_INITIALIZER;
  static int mtime = 0;
  if( m<0 ) m = mEtag;
  if( m & ETAG_DYNAMIC ) return 0;
  if( mtime==0 ) mtime = file_mtime(g.nameOfExe, ExtFILE);
  blob_appendf(&x,"%d%x", m, mtime);
  if( m & ETAG_HASH ){
    blob_appendf(&x, "/%s", zEHash);
  }else if( m & ETAG_DATA ){
    int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom");
    blob_appendf(&x, "/%x", iKey);
  }else if( m & ETAG_CONFIG ){