한 번에 1페이지가 아니라 루트 페이지로 시작하는 모든 웹사이트 페이지를 컬링 -IL하려면 어떻게 해야 합니까?

한 번에 1페이지가 아니라 루트 페이지로 시작하는 모든 웹사이트 페이지를 컬링 -IL하려면 어떻게 해야 합니까?

fastcgi가 모든 페이지를 캐시할 수 있도록 모든 웹사이트를 컬링 -IL해야 하고 cron 작업이나 24시간마다 다른 작업을 수행해야 합니다.vgo

웹페이지를 컬 -IL하지 않는 한 캐시는 적중하지 않으므로 웹사이트에서 사용할 수 있는 모든 웹페이지를 컬할 수 있는 무언가가 필요합니다.

다음과 같이 볼 수 있습니다.

root@ubuntu-s-1vcpu-1gb-amd-sfo3-01:~# curl -IL https://www.example.com
HTTP/2 200 
date: Thu, 23 Feb 2023 10:31:44 GMT
content-type: text/html; charset=UTF-8
link: <https://www.example.com/wp-json/>; rel="https://api.w.org/"
link: <https://www.example.com/wp-json/wp/v2/pages/16274>; rel="alternate"; type="application/json"
link: <https://www.example.com/>; rel=shortlink
x-fastcgi-cache: HIT
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=2K%2BxMLMMrvGpe%2FdpG38gU%2FKaBPBAL5I3rYNL5ATQ65wPM2qMnQmaCe2jLx88N%2B%2BHeUw1RRI5EnrYh9%2F6P5fj7xAipg%2FnOxi4IV8e4IqPWMyANW9JnKndXGfBZw0r3LtF1IEl"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 79df4b241af32f15-LAX
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400

답변1

그것이 당신이 거기에서 사용하는 WordPress입니다. 캐시를 준비하는 더 좋은 방법이 있다고 확신합니다.https://de.wordpress.org/plugins/search/cache+warm/

다음 코드를 사용하여 Warmup.sh와 같은 파일을 만듭니다.

#!/bin/bash

# URL of main Sitemap
sitemap_url="https://www.vgopromo.com/wp-sitemap.xml"

# Extract all Sitemap URLs
sitemap_urls=$(curl -s "$sitemap_url" | grep -oP '(?<=<loc>)[^<]+')

# Loop over and retrieve the individual URLs
for sitemap in $sitemap_urls; do
    urls=$(curl -s "$sitemap" | grep -oP '(?<=<loc>)[^<]+')
    for url in $urls; do
        curl -IL "$url"
    done
done

그러면 요청한 대로 수행됩니다.

이 파일을 실행하는 Cronjob을 사용할 수도 있습니다.

# Example: At minute 15 past every hour.
15 */1 * * * /bin/bash /root/warmup.sh

편집하다

이 수정된 코드는 하위 도메인도 정의하는 옵션을 추가합니다.

#!/bin/bash

# Array of Subdomains, just extend in same princip
subdomains=("www" "subdomain_2")

# Loop over Subdomains and retrieve URLs
for subdomain in "${subdomains[@]}"; do
    sitemap_url="https://$subdomain.vgopromo.com/wp-sitemap.xml"
    sitemap_urls=$(curl -s "$sitemap_url" | grep -oP '(?<=<loc>)[^<]+')
    for sitemap in $sitemap_urls; do
        urls=$(curl -s "$sitemap" | grep -oP '(?<=<loc>)[^<]+')
        for url in $urls; do
            curl -IL "$url"
        done
    done
done

저는 개인적으로 이 방법을 제안하겠습니다. 여러 프로젝트와 호환 가능

#!/bin/bash

# Array of Domains, just extend in same princip
domains=("https://www.vgopromo.com/wp-sitemap.xml" "https://example.vgopromo.com/wp-sitemap.xml")

# Loop over Domains and retrieve URLs
for domain in "${domains[@]}"; do
    sitemap_url="$domain"
    sitemap_urls=$(curl -s "$sitemap_url" | grep -oP '(?<=<loc>)[^<]+')
    for sitemap in $sitemap_urls; do
        urls=$(curl -s "$sitemap" | grep -oP '(?<=<loc>)[^<]+')
        for url in $urls; do
            curl -IL "$url"
        done
    done
done

관련 정보