An open API service indexing awesome lists of open source software.

https://github.com/gruns/iscacheable

A simple tool to determine if a URL is cacheable or not.
https://github.com/gruns/iscacheable

Last synced: over 1 year ago
JSON representation

A simple tool to determine if a URL is cacheable or not.

Awesome Lists containing this project

README

          

# IsCacheable

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.

### Usage

To use, provide `iscacheable` the URL to test and let it go to
work. `iscacheable` will then:

1. Send an HTTP `HEAD` request to the URL.
2. Fetch the response headers.
3. Determine if the response headers are cacheable.
4. Print `Cacheable.` if the URL is cacheable, `Not cacheable.` otherwise.
5. 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.

```python
>>> 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.

### Installation

Installing iscacheable with pip is easy.

```
$ pip install iscacheable
```