cacheControl method
The Cache-Control for the file at path, which is protected when
only an authorised caller may be sent it.
Implementation
String cacheControl(String path, {bool protected = false}) {
if (protected) return dvProtectedCacheControl;
final String name = path.split('/').last.toLowerCase();
if (_looksHashed(name) || immutable.any((String glob) => _glob(glob).hasMatch(path))) {
return _immutable;
}
if (name.endsWith('.html') || name.endsWith('.htm')) return documents;
if (maxAge == null && sMaxAge == null && staleWhileRevalidate == null) {
return 'public, no-cache';
}
return <String>[
'public',
'max-age=${maxAge ?? 0}',
if (sMaxAge != null) 's-maxage=$sMaxAge',
if (staleWhileRevalidate != null) 'stale-while-revalidate=$staleWhileRevalidate',
].join(', ');
}