Issue
We have found JsonResponse used in our custom module and AjaxResponse used in autocomplete field are cached after we enabled APE module. It turns out APE event subscriber does not check if the response is cacheable or not. So it probably would cache all plain response including JsonResponse, AjaxResponse, RedirectionResponse, and etc.

Solution
Check if the response implements CacheableResponseInterface interface like dynamic_page_cache module does.

    if (!$response instanceof CacheableResponseInterface) {
      return;
    }

Comments

eric.chenchao created an issue. See original summary.

eric.chenchao’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new1.08 KB

Here is the patch

steel-track’s picture

Apologies for the delay on this, I was on vacation. I think this fix makes a lot of sense. I'll commit and cut a new release.

  • steel-track committed fdb5fe0 on 8.x-1.x
    Issue #2892252 by eric.chenchao: Check if response is cacheable.
    
steel-track’s picture

Assigned: Unassigned » steel-track
Status: Needs review » Fixed
steel-track’s picture

Status: Fixed » Closed (fixed)
eric.chenchao’s picture

Thanks Dave. Just saw your message :D