Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruddra/cloudflare-google-fonts-cache
Use Cloudflare worker cache to serve google fonts.
https://github.com/ruddra/cloudflare-google-fonts-cache
cloudflare-workers
Last synced: 7 days ago
JSON representation
Use Cloudflare worker cache to serve google fonts.
- Host: GitHub
- URL: https://github.com/ruddra/cloudflare-google-fonts-cache
- Owner: ruddra
- License: mit
- Created: 2021-07-19T09:23:09.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-19T11:46:02.000Z (over 3 years ago)
- Last Synced: 2024-05-02T01:24:26.741Z (7 months ago)
- Topics: cloudflare-workers
- Language: JavaScript
- Homepage: https://ruddra.com/cloudflare-cache-google-fonts/
- Size: 5.86 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloudflare Worker for Google Fonts CDN Masking and Caching
This worker can be used to mask google font CDN with your own domain, so that you don't have to call or preconnect to google fonts from your html. Also, we are using worker cache to store the responses, so that we can make the calls faster.
## How it works
Basically if you point your domain ie `https://domain.com/fonts/*` to this worker, then you should be able to get responses just like google CDN. For example:
`https://domain.com/fonts/css2?family=Roboto:wght@400;700&display=swap` is same as `https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap`. Simillarly `https://domain.com/fonts/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2` actual font file ie woff2 file) is same as `https://fonts.gstatic.com/s/roboto/v27/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2`.## Contribute
Feel free to create a PR for any improvements.## License
MIT