This commit is contained in:
thosakwe 2017-06-15 22:20:58 -04:00
parent ed389479f5
commit 8f2ef4f740
3 changed files with 32 additions and 4 deletions

View file

@ -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 {

View file

@ -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:

View file

@ -4,7 +4,7 @@ environment:
sdk: ">=1.19.0"
homepage: https://github.com/angel-dart/static
author: Tobe O <thosakwe@gmail.com>
version: 1.2.0
version: 1.2.1
dependencies:
angel_framework: ^1.0.0-dev
cli_util: ^0.1.1