Skip to content

Commit e205387

Browse files
alrramathiasbynens
authored andcommitted
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 mathiasbynens#308.
1 parent 5cdfccf commit e205387

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

bin/httpcompression

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@
22

33
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL
44

5-
declare -r hUA="Mozilla/5.0 Gecko"
5+
# Useful Links:
6+
#
7+
# - HTTP/1.1 (RFC 2616) - Content Codings:
8+
# http://tools.ietf.org/html/rfc2616#section-3.5
9+
#
10+
# - SDCH Specification:
11+
# http://www.blogs.zeenor.com/wp-content/uploads/2011/01/Shared_Dictionary_Compression_over_HTTP.pdf
12+
13+
# Usage:
14+
#
15+
# httpcompression URL
16+
617
declare -r hAE="Accept-Encoding: gzip, deflate, sdch"
18+
declare -r hCC="Cache-Control: no-cache"
19+
declare -r hUA="Mozilla/5.0 Gecko"
720
declare -r maxConTime=15
821
declare -r maxTime=30
922

1023
declare availDicts="" dict="" dictClientID="" dicts="" headers="" i="" \
1124
indent="" url="" encoding="" urlHeaders=""
1225

1326
headers="$( curl --connect-timeout $maxConTime \
14-
-A "$hUA" `# Send a fake UA string for sites
15-
# that sniff it instead of using
16-
# the Accept-Encoding header` \
27+
-A "$hUA" `# Send a fake UA string for sites that sniff it
28+
# instead of using the Accept-Encoding header` \
1729
-D - `# Get response headers` \
1830
-H "$hAE" \
19-
-L `# If the page was moved to a different
20-
# location, redo the request` \
31+
-H "$hCC" `# Prevent intermediate proxies from caching the
32+
# response` \
33+
-L `# If the page was moved to a different location,
34+
# redo the request` \
2135
-m $maxTime \
2236
-s `# Don\'t show the progress meter` \
2337
-S `# Show error messages` \

0 commit comments

Comments
 (0)