PHP 5.5 이상에서 캐시파일 변경시 opcache_invalidate() 호출 #1379
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PHP 5.5 이상, opcache가 설치된 서버에서 파일 캐시를 사용할 경우 발생하는 문제입니다. 관리모듈에서 사이트 설정이나 모듈 설정을 변경하고 "저장"을 클릭하면 변경내역이 바로 적용되지 않고 예전의 값으로 돌아간 것처럼 보입니다. 약 3초 후에 페이지를 새로고침하면 변경내역이 적용된 상태로 나타나고요.
APC 등 과거의 옵코드 캐시와 달리, opcache는 PHP 파일이 변경되더라도 일정 시간이 지나기 전에는 다시 컴파일하지 않기 때문에 이런 현상이 발생합니다. 우분투 서버에서는 기본값이 2초입니다. 캐시파일이 변경되더라도 2초간은 예전의 내용이 계속 읽혀지는 거죠.
opcache가 설치된 서버에서 파일 캐시 핸들러의
put
또는delete
메소드를 호출하면 변경 또는 삭제된 파일을 즉시 opcache에서 삭제하여 재컴파일을 요구하도록 조치하였습니다. 파일 캐시 핸들러 외에도 PHP 파일을 작성한 후 곧바로 다시 include하여 사용하는 경우 언제든지 똑같은 문제가 발생할 수 있지만, 일단 가장 많이 사용하는 캐시 핸들러부터 수정하는 것이 좋겠습니다.