jvmtech / warmupcache
通过爬取选定的URL或网站,为Wormup Neos CMS提供全静态缓存或融合缓存。
0.1.1
2024-06-14 08:54 UTC
Requires
- flowpack/jobqueue-common: ^3.3.2
- neos/flow: ^7.0 || ^8.0 || dev-master
README
通过爬取URL或网站地图来预热您网站的缓存,并包括允许和拒绝的列表。
安装
composer require jvmtech/warmupcache
如何使用它?
默认情况下,指定的URL/网站地图将仅进行扫描。要预热所有爬取的URL,需要设置队列。
flow queue:setup warmupcache
然后执行以下命令之一,使用 --add-to-queue 参数将URL添加到队列中。
最后一步是队列执行。您可以通过标准方式执行一个作业后再执行另一个作业
./flow job:work warmupcache
watch ./flow queue:list # wait until warmupcache is zero
或者您可以使用以下并行执行(请注意,在这种情况下,您需要指定正确的限制(队列中的作业数量除以您将使用的进程数量))
seq 4 | xargs -I{} -P4 sh -c "FLOW_CONTEXT=Your/Context ./flow job:work warmupcache --limit 100 --verbose"
命令
cachewarmup:extracturls - 爬取URL以提取所有href。
当我们需要选择要预热的页面/子页面时很有用,例如产品页面的子页面。示例用法(扫描3个主页变体)
./flow cachewarmup:extracturls --urls=https://your.site/ch-de/institutional,https:/your.site/ch-de/pro,https://your.site/ch-de/private --add-to-queue
cachewarmup:extracturlsfromsitemap - 爬取网站地图以提取href。
当我们需要预热网站地图中的大多数页面时很有用。示例用法
./flow cachewarmup:extracturlsfromsitemap --sitemaps=https://your.site/ch-de/pro/sitemap.xml --add-to-queue
./flow cachewarmup:extracturlsfromsitemap --preset=homepage
预设配置
这两个命令都可以使用 --preset <preset_name>
参数,并使用包含以下内容的预定义设置:
- URL/网站地图列表,
- 允许列表/拒绝列表
- 限制(应加载多少页面)
- 附加URL设置(将添加到匹配指定模式的页面的后缀)
JvMTECH:
WarmupCache:
basicauth:
# login: ''
# pass: ''
presets:
# Example #1
# We want to warmup only subpages that are linked to from home page
# as we don't want to scan all insights or news
# skipping mailto & _Resources links
'homepage':
urls:
- 'https://your.site/ch-de/pro/'
- 'https://your.site/ch-de/private/'
allowlist:
# if values specified only pages matching pattern will be whitelisted
denylist:
- '/mailto\:/i' # to exclude all "mailto:" links
- '/\/_Resources\//i' # to exclude links containing "_Resources"
# limit: 0
# Example #2
# Each shareclass page has 3 functional subpages that are not in sitemap,
# but we want to have them cached - check addUrls section
'products':
sitemaps:
- 'https://your.site/ch-de/pro/sitemap.xml'
- 'https://your.site/ch-de/private/sitemap.xml'
allowlist:
- '/\/products\//i'
denylist:
limits: 0,0 # for each sitemap separated with comma (,)
addUrls: # links finishing with -currencySymbol are extended with subpages
'/prices.json': '/(-usd|-eur|-chf|-gbp)$/i'
'/productdocuments': '/(-usd|-eur|-chf|-gbp)$/i'
'/productdocumentssimple': '/(-usd|-eur|-chf|-gbp)$/i'
由 jvmtech.ch 提供