django-cloudflare-push
======================
About
-----
django-cloudflare-push is a small piece of middleware that looks at the list of
static files in each page that is requested (you need to be using some sort of
static files processor, like Django's built-in one), and [adds a Link
header](https://www.cloudflare.com/website-optimization/http2/serverpush/) that
CloudFlare uses to push the static files to the browser before the latter
requests them, using HTTP/2 Push.
Somewhat counter-intuitively, django-cloudflare-push is compatible with *any*
provider that supports HTTP/2 Push using Link headers, which is pretty much
most of them. For example, the Caddy webserver supports this with the `push`
directive, and this library will work just fine with that.
[![PyPI version](https://img.shields.io/pypi/v/django-cloudflare-push.svg)](https://pypi.python.org/pypi/django-cloudflare-push)
Installing django-cloudflare-push
---------------------------------
* Install django-cloudflare-push using pip: `pip install django-cloudflare-push`
* Add the middleware to your MIDDLEWARE setting:
```python
MIDDLEWARE = (
'django_cloudflare_push.middleware.push_middleware',
...
)
```
Done! Your static media will be pushed. You can test the middleware by looking
for the `Link` header.
Settings
--------
```python
CLOUDFLARE_PUSH_FILTER = lambda file: True
```
Allows you to customize what files will be sent to the client to be preloaded.
This setting should be set to a callable, which accepts a single parameter
(the name of the file to preload). By default, `django-cloudflare-push` pushes
all static files.
For instance, to push _only_ static CSS and JavaScript files:
```python
CLOUDFLARE_PUSH_FILTER = lambda x: x.endswith('.css') or x.endswith('.js')
```
Webserver configuration
-----------------------
Here's how to configure various webservers to work well with
`django-cloudflare-push`:
### nginx
If you're running nginx v1.13.9 or later, you can just include the
`http2_push_preload on` directive in your configuration:
```
server {
...
http2_push_preload on;
...
}
```
### Caddy
With Caddy, you can use the [`push` directive](https://caddyserver.com/docs/push):
```
push
```
...I know.
License
-------
This software is distributed under the BSD license.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共18个文件
py:3个
txt:3个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:django-cloudflare-push-0.2.1.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
django-cloudflare-push-0.2.1.tar.gz (18个子文件)
django-cloudflare-push-0.2.1
MANIFEST.in 85B
.travis.yml 484B
PKG-INFO 595B
django_cloudflare_push.egg-info
PKG-INFO 595B
not-zip-safe 1B
SOURCES.txt 407B
top_level.txt 23B
dependency_links.txt 1B
django_cloudflare_push
middleware.py 3KB
__init__.py 22B
tox.ini 221B
.gitchangelog.rc 6KB
CHANGELOG 0B
LICENSE 1KB
setup.cfg 153B
setup.py 951B
.gitignore 81B
README.md 2KB
共 18 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 12w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功