Refresh a proxy cache with Curl
2015-03-31
| Martin Hoppenheit
| 1 min read
If you try to download a file with Curl but keep getting wrong data there may be a web proxy getting in your way that holds an outdated version of the file in its cache.
To verify this take a look at the header data involved in your request:
$ curl --verbose http://example.net/foo
If the output contains a line like
X-Cache-Lookup: HIT from proxy.example.org
the proxy proxy.example.org
probably holds an old
version of the requested file in its cache. You can tell the proxy to
refresh its cache by including a Cache-Control
header with Curl’s -H
(or --header
)
flag:
$ curl --verbose -H 'Cache-Control: no-cache' http://example.net/foo
If it works you will get the current version of the file. The output will probably contain two lines like these, telling you that the proxy has indeed refreshed its cache:
X-Cache-Lookup: MISS from proxy.example.org
X-Cache-Lookup: HIT from proxy.example.org