WP REST Cache

설명

워드프레스 REST API 사용 시 속도 문제가 발생하시나요? 이 플러그인을 사용하면 워드프레스가 REST API 응답을 캐시하여 속도를 크게 향상시킬 수 있습니다.

이 플러그인은 다음을 제공합니다:

  • 모든 기본 워드프레스 REST API GET 중단점을 캐싱합니다.
  • (사용자 정의) 글 유형 중단점 캐싱.
  • (사용자 정의) 택소노미 중단점 캐싱.
  • 콘텐츠 일부가 편집되면 캐시를 자동으로 삭제합니다.
  • 모든 캐시를 수동으로 삭제합니다.
  • 특정 캐시를 수동으로 삭제합니다.
  • 캐시가 검색된 횟수를 나타내는 카운터입니다.
  • 캐시 시간이 초과되는 시간을 지정합니다.
  • 캐싱을 위한 사용자 정의 중단점 등록.
  • 자동 캐시 재생성.

WP REST Cache Pro
더욱 고급 기능을 원하시면 WP REST Cache Pro 플러그인을 확인해보세요:

  • 캐시를 사용자 정의 중단점을 wp-admin 인터페이스에서 구성하세요.
  • 중단점과의 관계를 구성하세요.
  • 코딩이 필요 없습니다.

워드프레스 내에서 설치

  1. ‘플러그인 > 새로 추가’를 클릭하세요(다중 사이트 설치인 경우 ‘내 사이트 > 네트워크 관리자 > 플러그인 > 새로 추가’를 클릭하세요).
  2. ‘WP REST Cache’를 검색하세요.
  3. 워드프레스의 ‘플러그인’ 메뉴를 통해 WP REST Cache 플러그인을 활성화하세요.
  4. 아래의 “활성화 후”로 이동하세요.

수동 설치

  1. wp-rest-cache 폴더를 /wp-content/plugins/ 디렉토리에 업로드하세요.
  2. 워드프레스의 ‘플러그인’ 메뉴를 통해 WP REST Cache 플러그인을 활성화하세요.
  3. 아래의 “활성화 후”로 이동하세요.

활성화 후

  1. ‘플러그인 > 필수’를 방문하세요(다중 사이트 설치인 경우 ‘내 사이트 > 네트워크 관리자 > 플러그인 > 필수’를 방문하세요).
  2. ‘WP REST Cache – Must-Use Plugin’이 있는지 확인하고, 없다면 WP REST Cache 플러그인의 /sources 폴더에서 wp-rest-cache.php 파일을 /wp-content/mu-plugins/ 폴더로 복사하세요.

선택 사항: WP REST Cache 플러그인에서 생성된 캐시의 기본 시간 제한은 1년으로 설정되어 있습니다. 이 설정을 변경하려면 다음을 수행하세요:

  1. ‘설정 > WP REST Cache’로 이동하세요.
  2. 캐시 시간 초과를 변경합니다.

스크린샷

  • WP REST Cache 플러그인에 대한 설정.
  • 캐시된 중단점 호출에 대한 개요.
  • 캐시된 단일 항목에 대한 개요입니다.
  • 캐시 세부 정보 페이지 – 캐시 정보.
  • 캐시 세부 정보 페이지 – 캐시 데이터.

FAQ

페이지/글을 편집했는데, 캐시를 지워야 하나요?

아니요, 플러그인은 방금 편집한 페이지/글과 관련된 모든 캐시를 자동으로 삭제합니다.

사용자 정의 글 유형을 생성했는데, 플러그인이 사용자 정의 글 유형 중단점을 캐시할까요?

네, 플러그인은 사용자 지정 글 유형의 중단점을 자동으로 캐시합니다. 사용자 지정 WP_REST_Controller를 생성하지 않은 경우, 중단점이 자동으로 캐시되지 않습니다.

사용자 정의 택소노미를 생성했는데, 플러그인이 택소노미 중단점을 캐시할까요?

네, 플러그인은 사용자 지정 분류의 중단점을 자동으로 캐시합니다. 사용자 지정 WP_REST_Controller를 생성하지 않은 경우, 중단점이 자동으로 캐시되지 않습니다.

사용자 정의 WP REST 중단점을 생성했는데, 플러그인이 이 중단점을 캐시할까요?

아니요, 플러그인은 WP REST Cache Pro 플러그인이나 wp_rest_cache/allowed_endpoints 훅을 사용하여 캐시하도록 지정하지 않는 한 사용자 정의 중단점을 캐시하지 않습니다(‘캐싱을 위해 사용자 지정 중단점을 등록할 수 있나요?’ 참조). 이렇게 하면 플러그인이 해당 중단점의 캐시를 자동으로 삭제하지 않습니다(캐시를 삭제해야 하는 시점을 알 수 있는 방법이 없기 때문입니다). 하지만 플러그인은 관계를 파악하려고 시도하며, 파악된 관계에 대해서는 관계가 수정되면 자동으로 캐시를 삭제합니다.

캐싱을 위해 내 중단점을 등록할 수 있나요?

네, 가능합니다! 저희 WP REST Cache Pro 플러그인을 사용하시면 wp-admin 인터페이스를 통해 간편하게 캐싱을 위한 중단점을 등록하실 수 있습니다. 또는 wp_rest_cache/allowed_endpoints 훅을 사용하여 다음과 같이 프로그래밍 방식으로 등록하실 수도 있습니다:

/**
 * Register the /wp-json/acf/v3/posts endpoint so it will be cached.
 */
function wprc_add_acf_posts_endpoint( $allowed_endpoints ) {
    if ( ! isset( $allowed_endpoints[ 'acf/v3' ] ) || ! in_array( 'posts', $allowed_endpoints[ 'acf/v3' ] ) ) {
        $allowed_endpoints[ 'acf/v3' ][] = 'posts';
    }
    return $allowed_endpoints;
}
add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_add_acf_posts_endpoint', 10, 1);

참고 사항: WP REST Cache 플러그인은 관련 항목이 편집되면 캐시된 데이터에서 관계를 감지하여 캐시를 자동으로 삭제하려고 시도하지만, 이러한 감지가 완벽하지 않으므로 캐시가 자동으로 삭제되지 않을 수 있습니다.

캐시되지 않도록 중단점의 등록을 취소할 수 있나요?

네, 가능합니다! wp_rest_cache/allowed_endpoints 후크를 다음과 같이 사용하세요:

/**
 * Unregister the /wp-json/wp/v2/comments endpoint so it will not be cached.
 */
function wprc_unregister_wp_comments_endpoint( $allowed_endpoints ) {
    if ( isset( $allowed_endpoints[ 'wp/v2' ] ) && ( $key = array_search( 'comments', $allowed_endpoints[ 'wp/v2' ] ) ) !== false ) {
        unset( $allowed_endpoints[ 'wp/v2' ][ $key ] );
    }
    return $allowed_endpoints;
}
add_filter( 'wp_rest_cache/allowed_endpoints', 'wprc_unregister_wp_comments_endpoint', 100, 1);

REST API 호출에서 캐싱을 사용하지 않도록 강제할 수 있나요?

네, 가능합니다! 호출에 GET 매개변수 skip_cache=1를 추가하면 캐싱이 사용되지 않습니다.

캐시 개요 페이지에서 객체 유형이 ‘알 수 없음’으로 표시됩니다. WP REST Cache 플러그인이 객체 유형을 올바르게 감지하도록 도울 수 있을까요?

네, 가능합니다! wp_rest_cache/determine_object_type 후크를 다음과 같이 사용하세요:

function wprc_determine_object_type( $object_type, $cache_key, $data, $uri ) {
    if ( $object_type !== 'unknown' || strpos( $uri, $your_namespace . '/' . $your_rest_base ) === false ) {
        return $object_type;
    }
    // Do your magic here
    $object_type = 'website';
    // Do your magic here
    return $object_type;
}
add_filter( 'wp_rest_cache/determine_object_type', 'wprc_determine_object_type', 10, 4 );

만료된 캐시를 자동으로 다시 생성할 수 있나요?

네, 가능합니다! 설정 > WP REST Cache로 이동하여 설정 탭에서 Enable cache regeneration 체크하면 만료되었거나 삭제된 캐시가 있는지 확인하고 재생성하는 크론 작업이 활성화됩니다. Regeneration interval 사용하면 재생성 프로세스의 실행 빈도를 설정할 수 있습니다. Max number regenerate caches 재생성 프로세스당 재생성되는 캐시 수를 제한합니다. 이는 서버에 재생성 호출이 너무 많이 발생하는 것을 방지하기 위한 것입니다.

wp-admin 표시줄에서 ‘REST 캐시 지우기’를 숨길 수 있나요?

네, 가능합니다! wp_rest_cache/display_clear_cache_button 후크를 다음과 같이 사용하세요:

function wprc_display_clear_cache_button( $show ) {
    return false;
}
add_filter('wp_rest_cache/display_clear_cache_button', 'wprc_display_clear_cache_button', 10, 1);

요청 헤더에 따라 캐시를 구별할 수 있나요?

네, 가능합니다! 두 가지 옵션이 있습니다:
1. 설정 > WP REST Cache로 이동하여 Global cacheable request headers를 추가하세요. 쉼표로 구분된 목록입니다. 이 헤더는 모든 중단점에 사용됩니다.
2. wp_rest_cache/cacheable_request_headers 훅을 사용하여 중단점 별로 사용할 요청 헤더를 지정하세요. 다음과 같습니다:

function wprc_add_cacheable_request_headers( $cacheable_headers ) {
    $cacheable_headers['wp/v2/posts'] = 'LANG';
    return $cacheable_headers;
}
add_filter('wp_rest_cache/cacheable_request_headers', 'wprc_add_cacheable_request_headers', 10, 1);

설정을 변경하고 캐시를 삭제할 수 있는 사용자를 변경할 수 있나요?

네, 가능합니다! wp_rest_cache/settings_capability 훅을 다음과 같이 사용하세요:

function wprc_change_settings_capability( $capability ) {
    // Change the capability to users who can edit posts.
    return 'edit_posts';
}
add_filter('wp_rest_cache/settings_capability', 'wprc_change_settings_capability', 10, 1);

WP CLI를 사용하여 명령줄에서 캐시를 삭제할 수 있나요?

네, 가능합니다! wp wp-rest-cache flush 명령을 사용하여 캐시를 삭제하세요. 모든 옵션을 보려면 wp wp-rest-cache flush --help 입력하세요.

Redis Object Cache가 지원되나요?

저희는 워드프레스 임시 API를 사용하고 있으므로 임시 API를 통해 Redis 캐싱을 활성화하는 Redis Object Cache 플러그인을 사용하는 한 지원됩니다.

보안 버그를 어떻게 신고할 수 있나요?

Patchstack 취약점 공개 프로그램을 통해 보안 버그를 신고할 수 있습니다. Patchstack 팀은 모든 보안 취약점의 검증, 분류 및 처리를 지원합니다. 보안 취약점을 신고해 주세요.

후기

2025년 10월 1일
Nice one! Decreased response time by almost 60%.
2025년 8월 28일 답글 1개
This plugin is excellent and works exactly as advertised. Definitely worth a perfect rating. I do think the FAQ could be expanded a little more to mention process_cache_relations for custom REST endpoints, however. I only found my solution buried in other users’ threads. I had wrongly assumed that providing the object type manually via the determine_object_type hook was equivalent to making object relationships work, which is clearly not the case. Overall, a really great plugin and very well thought-out.
2025년 4월 11일 답글 4개
Using this plugin has made my API for filtering products go from finishing the filtering and reaching the user in 2.3 seconds to reaching the user in about 200 ms. A huge improvement indeed. However, I’ve noticed two things that slowly drive me insane: The add_filter for hiding the REST API button in the admin panel isn’t working. Why does this need a filter at all? Just make it a setting. I don’t get it. There is a serious lack of settings for this plugin. What if I want to cache one API route shorter than another? That’s currently impossible. Where’s the “regenerate all caches” button? This might very well be the only caching plugin without such a button. Yes, it has a “Clear all”, but no “Regenerate all”. This is a solid 5/5 if they add the above. I’ve yet to find a better solution that doesn’t involve Cloudflare. Thanks for the plugin!
2024년 4월 28일
Great plugin! I use it for a headless WordPress instance with Nuxt 3, and it works perfectly fine. The only thing I needed to change was the API endpoint since I created a custom endpoint to the route. But the FAQ cleared this up quickly and it works flawlessly. As a small suggestion I’d propose to add this option to the plugin’s settings page for easier access.
2024년 3월 12일
It’s been years since I touched wordpress or php. My usecase was very tricky and not doable out of the box. It worked out great in the end and the response time is now 4-5 times quicker. Amazing. But the best part is how quickly Richard answered to my noob questions and even fixed a bug I found. If you ever need a beta tester! Hit me up <3
모든 42 평가 읽기

기여자 & 개발자

“WP REST Cache”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에 기여하였습니다.

기여자

“WP REST Cache”(이)가 5 개 언어로 번역되었습니다. 기여해 주셔서 번역자님께 감사드립니다.

자국어로 “WP REST Cache”(을)를 번역하세요.

개발에 관심이 있으십니까?

코드 탐색하기는, SVN 저장소를 확인하시거나, 개발 기록RSS로 구독하세요.

변경이력

2025.2.0

출시일: 2025년 12월 15일

Improvement: Also flush caches when only the (post) meta is updated.

2025.1.8

출시일: 2025년 10월 14일

Improvement: Add option to flush or delete cache to cache details page.

2025.1.7

출시일: 2025년 9월 1일

Fix: Incorrect loading of translations in some cases.

2025.1.6

출시일: 2025년 8월 19일

Fix: Remove load_plugin_textdomain as it is no longer needed as of WP 4.6

2025.1.5

출시일: 2025년 8월 18일

Fix: incorrect url when regenerating expired caches
Fix: PHP Notice _load_textdomain_just_in_time was called incorrectly

2025.1.4

출시일: 2025년 6월 25일

수정: 업데이트하기 전에 기존 기본 키를 더 잘 검사합니다.

2025.1.3

출시일: 2025년 6월 25일

수정: 기본 키를 삭제하기 전에 기본 키가 존재하는지 확인합니다.

2025.1.2

출시일: 2025년 6월 11일

수정: 해당 글이 삭제되거나 게시 취소될 때 댓글 중단점이 삭제되도록 했습니다.
개선: FAQ에 VDP를 추가했습니다.

2025.1.1

출시일: 2025년 6월 6일

수정: 플러그인에서 경로 탐색 취약점이 발견되어 수정되었습니다. Darius Sveikauskas가 해당 취약점을 보고했습니다.

2025.1.0

출시일: 2025년 4월 10일

개선: 새로운 미디어가 업로드되면 미디어 중단점 캐시를 삭제합니다.

Earlier versions

이전 버전의 변경 내역은 Github의 변경 내역을 참조하세요.