Skip to content
Snippets Groups Projects

Cacheable HTML and JSON responses handled differently when HTTP 4xx occurs

3 files
+ 33
0
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -2,6 +2,7 @@
namespace Drupal\dynamic_page_cache_test;
use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableResponse;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\user\Entity\User;
@@ -25,6 +26,16 @@ public function response() {
return new Response('foobar');
}
/**
* A route returning a cacheable JSON response.
*
* @return \Drupal\Core\Cache\CacheableJsonResponse
* The response object.
*/
public function cacheableJsonResponse(): CacheableJsonResponse {
return new CacheableJsonResponse(['OK']);
}
/**
* A route returning a CacheableResponse object.
*
Loading