Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: lib/devc.dart

Issue 1131933003: Load time improvements (fixes #140) (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/runtime/messages_widget.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/devc.dart
diff --git a/lib/devc.dart b/lib/devc.dart
index 66627e826b0630b0b4e0080cea1ec00e22cdc96b..8ab4257675a499d9f31465f2fb025f0636ebccce 100644
--- a/lib/devc.dart
+++ b/lib/devc.dart
@@ -290,22 +290,16 @@ class CompilerServer {
if (isEntryPage) compiler._runAgain();
// To help browsers cache resources that don't change, we serve these
- // resources under a path containing their hash:
- // /cached/{hash}/{path-to-file.js}
- bool isCached = segments.length > 1 && segments[0] == 'cached';
- if (isCached) {
- // Changing the request lets us record that the hash prefix is handled
- // here, and that the underlying handler should use the rest of the url to
- // determine where to find the resource in the file system.
- request = request.change(path: path.join('cached', segments[1]));
- }
+ // resources by adding a query parameter containing their hash:
+ // /{path-to-file.js}?____cached={hash}
+ var hash = request.url.queryParameters['____cached'];
var response = handler(request);
- var policy = isCached ? 'max-age=${24 * 60 * 60}' : 'no-cache';
+ var policy = hash != null ? 'max-age=${24 * 60 * 60}' : 'no-cache';
var headers = {'cache-control': policy};
- if (isCached) {
+ if (hash != null) {
// Note: the cache-control header should be enough, but this doesn't hurt
// and can help renew the policy after it expires.
- headers['ETag'] = segments[1];
+ headers['ETag'] = hash;
}
return response.change(headers: headers);
};
« no previous file with comments | « no previous file | lib/runtime/messages_widget.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698