diff --git a/lib/src/cache.dart b/lib/src/cache.dart index f75f2635..8e093733 100644 --- a/lib/src/cache.dart +++ b/lib/src/cache.dart @@ -95,7 +95,15 @@ class CachingVirtualDirectory extends VirtualDirectory { return super.serveFile(file, stat, req, res); } - if (noCache == true) { + bool shouldNotCache = noCache == true; + + if (!shouldNotCache) { + shouldNotCache = + req.headers.value(HttpHeaders.CACHE_CONTROL) == 'no-cache' || + req.headers.value(HttpHeaders.PRAGMA) == 'no-cache'; + } + + if (shouldNotCache) { res.headers[HttpHeaders.CACHE_CONTROL] = 'private, max-age=0, no-cache'; return super.serveFile(file, stat, req, res); } else { @@ -181,7 +189,15 @@ class CachingVirtualDirectory extends VirtualDirectory { return super.serveAsset(fileInfo, req, res); } - if (noCache == true) { + bool shouldNotCache = noCache == true; + + if (!shouldNotCache) { + shouldNotCache = + req.headers.value(HttpHeaders.CACHE_CONTROL) == 'no-cache' || + req.headers.value(HttpHeaders.PRAGMA) == 'no-cache'; + } + + if (shouldNotCache) { res.headers[HttpHeaders.CACHE_CONTROL] = 'private, max-age=0, no-cache'; return super.serveAsset(fileInfo, req, res); } else { diff --git a/lib/src/virtual_directory.dart b/lib/src/virtual_directory.dart index 9a7f1717..be22b073 100644 --- a/lib/src/virtual_directory.dart +++ b/lib/src/virtual_directory.dart @@ -217,6 +217,16 @@ class VirtualDirectory implements AngelPlugin { if (await index.exists()) { return await serveFile(index, stat, req, res); } + + // Try to compile an asset + if (_transformerMap.isNotEmpty && + _transformerMap.containsKey(index.absolute.path)) { + return await serveAsset( + new FileInfo.fromFile( + new File(_transformerMap[index.absolute.path])), + req, + res); + } } return true; @@ -358,7 +368,9 @@ class VirtualDirectory implements AngelPlugin { var asset = new FileInfo.fromFile(entity); var compiled = await compileAsset(asset); if (compiled == null) - p.finish(message: '"${entity.absolute.path}" did not require compilation; skipping it.'); + p.finish( + message: + '"${entity.absolute.path}" did not require compilation; skipping it.'); else { p.finish( message: diff --git a/pubspec.yaml b/pubspec.yaml index 03bdcd62..b951db6c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,7 +4,7 @@ environment: sdk: ">=1.19.0" homepage: https://github.com/angel-dart/static author: Tobe O -version: 1.2.0 +version: 1.2.1 dependencies: angel_framework: ^1.0.0-dev cli_util: ^0.1.1