Fossil SCM

Optimizations to the ETag implementation.

drh 2018-02-24 03:47 UTC etags-cache-control
Commit 2588d447839e1b44ef1408e0fd556a8bfefbfee8710abb8d8ecd52f81db9f34d
1 file changed +3 -2
+3 -2
--- src/etag.c
+++ src/etag.c
@@ -129,10 +129,11 @@
129129
** is checked, and if it contains a compatible ETag, then a
130130
** 304 Not Modified return is generated and execution aborts. This
131131
** routine does not return if the 304 is generated.
132132
*/
133133
void etag_require(int code){
134
+ if( (mEtag & code)==code ) return;
134135
mEtag |= code;
135136
etag_check();
136137
}
137138
void etag_require_hash(const char *zHash){
138139
if( zHash ){
@@ -178,14 +179,14 @@
178179
** The other elements are only present if the appropriate mask bits
179180
** appear in the first character.
180181
*/
181182
char *etag_generate(int m){
182183
Blob x = BLOB_INITIALIZER;
183
- int mtime;
184
+ static int mtime = 0;
184185
if( m<0 ) m = mEtag;
185186
if( m & ETAG_DYNAMIC ) return 0;
186
- mtime = file_mtime(g.nameOfExe, ExtFILE);
187
+ if( mtime==0 ) mtime = file_mtime(g.nameOfExe, ExtFILE);
187188
blob_appendf(&x,"%d%x", m, mtime);
188189
if( m & ETAG_HASH ){
189190
blob_appendf(&x, "/%s", zEHash);
190191
}else if( m & ETAG_DATA ){
191192
int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom");
192193
--- src/etag.c
+++ src/etag.c
@@ -129,10 +129,11 @@
129 ** is checked, and if it contains a compatible ETag, then a
130 ** 304 Not Modified return is generated and execution aborts. This
131 ** routine does not return if the 304 is generated.
132 */
133 void etag_require(int code){
 
134 mEtag |= code;
135 etag_check();
136 }
137 void etag_require_hash(const char *zHash){
138 if( zHash ){
@@ -178,14 +179,14 @@
178 ** The other elements are only present if the appropriate mask bits
179 ** appear in the first character.
180 */
181 char *etag_generate(int m){
182 Blob x = BLOB_INITIALIZER;
183 int mtime;
184 if( m<0 ) m = mEtag;
185 if( m & ETAG_DYNAMIC ) return 0;
186 mtime = file_mtime(g.nameOfExe, ExtFILE);
187 blob_appendf(&x,"%d%x", m, mtime);
188 if( m & ETAG_HASH ){
189 blob_appendf(&x, "/%s", zEHash);
190 }else if( m & ETAG_DATA ){
191 int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom");
192
--- src/etag.c
+++ src/etag.c
@@ -129,10 +129,11 @@
129 ** is checked, and if it contains a compatible ETag, then a
130 ** 304 Not Modified return is generated and execution aborts. This
131 ** routine does not return if the 304 is generated.
132 */
133 void etag_require(int code){
134 if( (mEtag & code)==code ) return;
135 mEtag |= code;
136 etag_check();
137 }
138 void etag_require_hash(const char *zHash){
139 if( zHash ){
@@ -178,14 +179,14 @@
179 ** The other elements are only present if the appropriate mask bits
180 ** appear in the first character.
181 */
182 char *etag_generate(int m){
183 Blob x = BLOB_INITIALIZER;
184 static int mtime = 0;
185 if( m<0 ) m = mEtag;
186 if( m & ETAG_DYNAMIC ) return 0;
187 if( mtime==0 ) mtime = file_mtime(g.nameOfExe, ExtFILE);
188 blob_appendf(&x,"%d%x", m, mtime);
189 if( m & ETAG_HASH ){
190 blob_appendf(&x, "/%s", zEHash);
191 }else if( m & ETAG_DATA ){
192 int iKey = db_int(0, "SELECT max(rcvid) FROM rcvfrom");
193

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button