Skip to content

Instantly share code, notes, and snippets.

@jefftriplett
Last active March 24, 2021 02:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jefftriplett/2b24997e377da787e922288d8925aa34 to your computer and use it in GitHub Desktop.
Save jefftriplett/2b24997e377da787e922288d8925aa34 to your computer and use it in GitHub Desktop.
This is a quick script to check the "CF-Cache-Status" header to see if Cloudflare is serving your content out of cache.
import frontmatter
import requests
import typer
def main(url: str):
request = requests.get(url)
post = frontmatter.loads("")
headers = request.headers
post["headers"] = {}
for header in headers:
post["headers"][header] = headers[header]
typer.secho(f"Age: {request.headers.get('Age')}", fg="yellow")
typer.secho(f"CF-Cache-Status: {request.headers['CF-Cache-Status']}", fg="yellow")
typer.secho(frontmatter.dumps(post), fg="blue")
if __name__ == "__main__":
typer.run(main)
python-frontmatter
requests
typer
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile
#
certifi==2020.6.20 # via requests
chardet==3.0.4 # via requests
click==7.1.2 # via typer
idna==2.10 # via requests
python-frontmatter==0.5.0 # via -r requirements.in
pyyaml==5.3.1 # via python-frontmatter
requests==2.24.0 # via -r requirements.in
six==1.15.0 # via python-frontmatter
typer==0.3.1 # via -r requirements.in
urllib3==1.25.10 # via requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment