Fossil SCM
Enable cache of the CSS style sheet.
Commit
0c1de587f974534c1b9bb348eb72a6d5f0322bd71402cf30545a33476e76e75e
Parent
b1e811c3e705432…
1 file changed
+12
-2
+12
-2
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -1279,15 +1279,24 @@ | ||
| 1279 | 1279 | ** that the style sheet is cacheable. |
| 1280 | 1280 | */ |
| 1281 | 1281 | void page_style_css(void){ |
| 1282 | 1282 | Blob css = empty_blob; |
| 1283 | 1283 | int i; |
| 1284 | - const char * zDefaults; | |
| 1284 | + const char *zDefaults; | |
| 1285 | 1285 | const char *zSkin; |
| 1286 | - | |
| 1286 | + const char *zRequestUri = P("REQUEST_URI"); | |
| 1287 | + const char *zScriptName = P("SCRIPT_NAME"); | |
| 1288 | + const char *zKey = 0; | |
| 1287 | 1289 | cgi_set_content_type("text/css"); |
| 1288 | 1290 | etag_check(0, 0); |
| 1291 | + if( zRequestUri && zScriptName && strlen(zScriptName)<strlen(zRequestUri) ){ | |
| 1292 | + zKey = zRequestUri + strlen(zScriptName); | |
| 1293 | + } | |
| 1294 | + if( zKey && cache_read(cgi_output_blob(), zKey) ){ | |
| 1295 | + g.isConst = 1; | |
| 1296 | + return; | |
| 1297 | + } | |
| 1289 | 1298 | /* Emit all default rules... */ |
| 1290 | 1299 | zDefaults = (const char*)builtin_file("default.css", &i); |
| 1291 | 1300 | blob_append(&css, zDefaults, i); |
| 1292 | 1301 | /* Page-specific CSS, if any... */ |
| 1293 | 1302 | page_style_css_append_page_style(&css); |
| @@ -1306,10 +1315,11 @@ | ||
| 1306 | 1315 | Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); |
| 1307 | 1316 | Th_Store("home", g.zTop); |
| 1308 | 1317 | image_url_var("logo"); |
| 1309 | 1318 | image_url_var("background"); |
| 1310 | 1319 | Th_Render(blob_str(&css)); |
| 1320 | + if( zKey ) cache_write(cgi_output_blob(), zKey); | |
| 1311 | 1321 | blob_reset(&css); |
| 1312 | 1322 | |
| 1313 | 1323 | /* Tell CGI that the content returned by this page is considered cacheable */ |
| 1314 | 1324 | g.isConst = 1; |
| 1315 | 1325 | } |
| 1316 | 1326 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1279,15 +1279,24 @@ | |
| 1279 | ** that the style sheet is cacheable. |
| 1280 | */ |
| 1281 | void page_style_css(void){ |
| 1282 | Blob css = empty_blob; |
| 1283 | int i; |
| 1284 | const char * zDefaults; |
| 1285 | const char *zSkin; |
| 1286 | |
| 1287 | cgi_set_content_type("text/css"); |
| 1288 | etag_check(0, 0); |
| 1289 | /* Emit all default rules... */ |
| 1290 | zDefaults = (const char*)builtin_file("default.css", &i); |
| 1291 | blob_append(&css, zDefaults, i); |
| 1292 | /* Page-specific CSS, if any... */ |
| 1293 | page_style_css_append_page_style(&css); |
| @@ -1306,10 +1315,11 @@ | |
| 1306 | Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); |
| 1307 | Th_Store("home", g.zTop); |
| 1308 | image_url_var("logo"); |
| 1309 | image_url_var("background"); |
| 1310 | Th_Render(blob_str(&css)); |
| 1311 | blob_reset(&css); |
| 1312 | |
| 1313 | /* Tell CGI that the content returned by this page is considered cacheable */ |
| 1314 | g.isConst = 1; |
| 1315 | } |
| 1316 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -1279,15 +1279,24 @@ | |
| 1279 | ** that the style sheet is cacheable. |
| 1280 | */ |
| 1281 | void page_style_css(void){ |
| 1282 | Blob css = empty_blob; |
| 1283 | int i; |
| 1284 | const char *zDefaults; |
| 1285 | const char *zSkin; |
| 1286 | const char *zRequestUri = P("REQUEST_URI"); |
| 1287 | const char *zScriptName = P("SCRIPT_NAME"); |
| 1288 | const char *zKey = 0; |
| 1289 | cgi_set_content_type("text/css"); |
| 1290 | etag_check(0, 0); |
| 1291 | if( zRequestUri && zScriptName && strlen(zScriptName)<strlen(zRequestUri) ){ |
| 1292 | zKey = zRequestUri + strlen(zScriptName); |
| 1293 | } |
| 1294 | if( zKey && cache_read(cgi_output_blob(), zKey) ){ |
| 1295 | g.isConst = 1; |
| 1296 | return; |
| 1297 | } |
| 1298 | /* Emit all default rules... */ |
| 1299 | zDefaults = (const char*)builtin_file("default.css", &i); |
| 1300 | blob_append(&css, zDefaults, i); |
| 1301 | /* Page-specific CSS, if any... */ |
| 1302 | page_style_css_append_page_style(&css); |
| @@ -1306,10 +1315,11 @@ | |
| 1315 | Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL); |
| 1316 | Th_Store("home", g.zTop); |
| 1317 | image_url_var("logo"); |
| 1318 | image_url_var("background"); |
| 1319 | Th_Render(blob_str(&css)); |
| 1320 | if( zKey ) cache_write(cgi_output_blob(), zKey); |
| 1321 | blob_reset(&css); |
| 1322 | |
| 1323 | /* Tell CGI that the content returned by this page is considered cacheable */ |
| 1324 | g.isConst = 1; |
| 1325 | } |
| 1326 |