iscacheable is simple tool to determine if a URL is cacheable or not. It both prints whether the URL is cacheable to stdout and exits with 0 if the URL is cacheable or 1 if it's not cacheable.
Once installed, iscacheable
is available as a command.
To use, provide iscacheable
the URL to test and let it go to
work. iscacheable
will then:
- Send an HTTP
HEAD
request to the URL. - Fetch the response headers.
- Determine if the response headers are cacheable.
- Print
Cacheable.
if the URL is cacheable,Not cacheable.
otherwise. - Exit with exit code 0 if URL is cacheable, 1 otherwise.
Example:
$ iscacheable https://www.google.com
Not cacheable.
$ echo $?
1
$ iscacheable https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png
Cacheable.
$ echo $?
0
Of course iscacheable can also be used programmatically, too.
>>> from iscacheable import determineCacheability
>>>
>>> determineCacheability('https://www.google.com')
False
>>> determineCacheability('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png')
True
That's it. Simple.
Installing iscacheable with pip is easy.
$ pip install iscacheable