Do not send Cache-Tags header if Cache-control: no-cache

Created on 31 May 2018, about 6 years ago
Updated 4 May 2023, about 1 year ago

Hello!

There is a known limit on maximum header length in many webservers. See ✨ Minify the cache tags sent in the header Needs work .

From my experience the most likely case when you are gonna have the longest Cache-tags headers is when you do some website-administrator tasks like updating things in the admin UI; doing import of entities, etc. Those pages are normally not cached by Drupal cache API layer, nonetheless this module would send the "Cache-Tags" header. This "Cache-Tags" header would be useless because the page would come with "Cache-control: no-cache" so no CDN/reverse proxy would cache it anyway. However, you do run the risk of hitting the 8kb limit; and if you hit this limit you would face a 500 HTTP error.

I derive that on such "Cache-control: no-cache" pages:

  • you are sending useless headers
  • you're running a risk of hitting the header size limit without any theoretical gain in caching

Both are negative things. Wouldn't it be a good idea to add one additional EventSubscriber to this module to unset the "Cache-tags" header if the "Cache-control" one contains "no-cache"? The patch wouldn't be difficult but I wanted to confirm my logic is reasonable before coding. Do you see any pitfalls in the stuff I've put above?

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine bucefal91

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
Production build 0.69.0 2024