diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-03-16 19:55:11 +0000 |
---|---|---|
committer | Kristian Lyngstol <kly@kly.no> | 2016-03-16 19:55:11 +0000 |
commit | e3244501e89df95c6cb3ad2b9efc7e708ec9b1bb (patch) | |
tree | 420b1acdafaf1378b663b54ec8e2bfe9d71e9c93 | |
parent | 314bc052854aabb44dd9272ddd82176be5c469d5 (diff) |
NMS: Fix production-grade cache :D
Seems to work fine, both with caching and cache invalidation. (e.g.: moving
a switch, adding ac omment).
Might have missed something, of course.
-rw-r--r-- | web/etc/varnish/nms.vcl | 17 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/private/comment-add | 1 | ||||
-rwxr-xr-x | web/nms.gathering.org/api/private/switch-add | 1 |
3 files changed, 5 insertions, 14 deletions
diff --git a/web/etc/varnish/nms.vcl b/web/etc/varnish/nms.vcl index 4f1a855..6349238 100644 --- a/web/etc/varnish/nms.vcl +++ b/web/etc/varnish/nms.vcl @@ -30,7 +30,6 @@ sub vcl_recv { return (pass); } - return (pass); # Brukes ikke. Cookies er for nubs. unset req.http.Cookie; @@ -47,18 +46,8 @@ sub vcl_hash { # Mauve magi. Hva nĂ¥ enn det er. # Dette er WIP - Skal flyttes til backend sub vcl_backend_response { - if (beresp.status == 200) { - set beresp.ttl = 2s; - } else { - # Vi cacher feilmeldinger, fordi vi er kule. - set beresp.ttl = 1s; - } - - if(bereq.url ~ "port-state.pl" && beresp.status == 200) { - set beresp.ttl = 1s; - } - if (beresp.status == 200 && bereq.url ~ "now=") { - # Historisk data kan vi cache cirka evig - set beresp.ttl = 60m; + set beresp.http.x-url = bereq.url; + if (beresp.http.x-ban) { + ban("obj.http.x-url ~ " + beresp.http.x-ban); } } diff --git a/web/nms.gathering.org/api/private/comment-add b/web/nms.gathering.org/api/private/comment-add index 2f8b0b7..26ff734 100755 --- a/web/nms.gathering.org/api/private/comment-add +++ b/web/nms.gathering.org/api/private/comment-add @@ -20,4 +20,5 @@ $nms::web::cc{'max-age'} = '0'; $nms::web::cc{'stale-while-revalidate'} = '0'; $nms::web::json{'state'} = 'ok'; +print "X-ban: /api/private/comments\n"; finalize_output(); diff --git a/web/nms.gathering.org/api/private/switch-add b/web/nms.gathering.org/api/private/switch-add index 92479f0..e50b9a5 100755 --- a/web/nms.gathering.org/api/private/switch-add +++ b/web/nms.gathering.org/api/private/switch-add @@ -112,4 +112,5 @@ foreach my $tmp2 (@tmp) { $json{'switches_addded'} = \@added; $json{'switches_updated'} = \@dups; +print "X-ban: /api/.*switches.*\n"; finalize_output(); |