aboutsummaryrefslogtreecommitdiffstats
path: root/bin/httpcompression
diff options
context:
space:
mode:
authorCătălin Mariș <alrraa@gmail.com>2013-12-07 22:17:46 +0200
committerMathias Bynens <mathias@qiwi.be>2013-12-08 14:51:05 +0100
commite20538715d3daf0e11ab1482abda2d0063833c99 (patch)
tree08829b17e8b9243bf787768430dfea50d7bb15f2 /bin/httpcompression
parent5cdfccf8f5ea35d90034ebca0dfd1e140bf580fc (diff)
downloaddotfiles-e20538715d3daf0e11ab1482abda2d0063833c99.tar.gz
dotfiles-e20538715d3daf0e11ab1482abda2d0063833c99.tar.bz2
dotfiles-e20538715d3daf0e11ab1482abda2d0063833c99.zip
bin: Make `httpcompression` prevent caching
In some cases, intermediate proxies ignore the `Content-Encoding` header altogether. Sending `Cache-Control no-cache` as a request header solves this problem by forcing validation of the resources in the intermediate proxies, thereby, ensuring that every request is fetched from the origin server. Ref. alrra/dotfiles#2. Closes #308.
Diffstat (limited to 'bin/httpcompression')
-rwxr-xr-xbin/httpcompression26
1 files changed, 20 insertions, 6 deletions
diff --git a/bin/httpcompression b/bin/httpcompression
index 444f719..9f5163c 100755
--- a/bin/httpcompression
+++ b/bin/httpcompression
@@ -2,8 +2,21 @@
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL
-declare -r hUA="Mozilla/5.0 Gecko"
+# Useful Links:
+#
+# - HTTP/1.1 (RFC 2616) - Content Codings:
+# http://tools.ietf.org/html/rfc2616#section-3.5
+#
+# - SDCH Specification:
+# http://www.blogs.zeenor.com/wp-content/uploads/2011/01/Shared_Dictionary_Compression_over_HTTP.pdf
+
+# Usage:
+#
+# httpcompression URL
+
declare -r hAE="Accept-Encoding: gzip, deflate, sdch"
+declare -r hCC="Cache-Control: no-cache"
+declare -r hUA="Mozilla/5.0 Gecko"
declare -r maxConTime=15
declare -r maxTime=30
@@ -11,13 +24,14 @@ declare availDicts="" dict="" dictClientID="" dicts="" headers="" i="" \
indent="" url="" encoding="" urlHeaders=""
headers="$( curl --connect-timeout $maxConTime \
- -A "$hUA" `# Send a fake UA string for sites
- # that sniff it instead of using
- # the Accept-Encoding header` \
+ -A "$hUA" `# Send a fake UA string for sites that sniff it
+ # instead of using the Accept-Encoding header` \
-D - `# Get response headers` \
-H "$hAE" \
- -L `# If the page was moved to a different
- # location, redo the request` \
+ -H "$hCC" `# Prevent intermediate proxies from caching the
+ # response` \
+ -L `# If the page was moved to a different location,
+ # redo the request` \
-m $maxTime \
-s `# Don\'t show the progress meter` \
-S `# Show error messages` \