From 3c507ecccb1ee05f58d195d9579a3735d2d26fcc Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sun, 1 Apr 2018 22:30:21 -0400 Subject: [PATCH] Only GET and HEAD --- lib/src/cache.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/src/cache.dart b/lib/src/cache.dart index 181a0af0..9fd7df9b 100644 --- a/lib/src/cache.dart +++ b/lib/src/cache.dart @@ -33,6 +33,8 @@ class ResponseCache { /// /// This prevents the server from even having to access the cache, and plays very well with static assets. Future ifModifiedSince(RequestContext req, ResponseContext res) async { + if (req.method != 'GET' && req.method != 'HEAD') return true; + if (req.headers.value('if-modified-since') != null) { var modifiedSince = fmt .parse(req.headers.value('if-modified-since').replaceAll('GMT', '')); @@ -58,6 +60,7 @@ class ResponseCache { /// Serves content from the cache, if applicable. Future handleRequest(RequestContext req, ResponseContext res) async { if (!await ifModifiedSince(req, res)) return false; + if (req.method != 'GET' && req.method != 'HEAD') return true; // Check if there is a cache entry. for (var pattern in patterns) { @@ -89,6 +92,7 @@ class ResponseCache { Future responseFinalizer( RequestContext req, ResponseContext res) async { if (res.statusCode == 304) return true; + if (req.method != 'GET' && req.method != 'HEAD') return true; // Check if there is a cache entry. for (var pattern in patterns) {