This is a Cloudflare worker utilizing its Cache API to cache and serve pictures for RSS feeds.
You can use the FreshRSS image cache plugin to rewrite the RSS feeds to this caching URL.
-
edit
wrangler.toml
and set its route and fallback figure url. For example:route = "https://example.com/piccache" [vars] FALLBACK_FIGURE = "https://http.cat/404.jpg"
The CF worker will be bind to the route specified, and when unable to retrieve the figure, it will return
FALLBACK_FIGURE
instead. You may also remove the line ofroute
and it will use*.workers.dev
instead. -
Add secrets of
APITOKEN
Use
wrangler secret put APITOKEN
to specify the access token. This should be consistent with image cache plugin'saccess_token
. -
Deploy the worker
-
Configure the image cache plugin
First, upload the plugin FreshRSS image cache plugin to your freshRSS instance with this guide.
If you use a route like
https://example.com/piccache
, the image cache plugin should be configured as:cache_url: "https://example.com/piccache?url=" post_url: "https://example.com/piccache" access_token: "<AS THE APITOKEN ABOVE>" url_encode: true
If you don't use route and get a
*.workers.dev
for your worker, the image cache plugin should be configured as:cache_url: "https://some.workers.dev/?url=" post_url: "https://some.workers.dev/" access_token: "<AS THE APITOKEN ABOVE>" url_encode: true
Some RSS feeds may mis-configured their figure loading policies, and cannot retrieve the figure without a specific header. Consider add the URL-headers pair to src/index.ts:25
.