Views metatag "expires" doesn't accept zero (0)

Created on 30 August 2024, 8 months ago

Problem/Motivation

To mitigate browser caching of a Views page, I attempted to add recommended cache control headers:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

The problem is that the Expires input doesn't accept the number zero. After saving the View, the input reverts to empty

Steps to reproduce

Enable the Metatag Views module
Add the above values to the Advanced Metatags list on a Views Page.
Save the View.
The Expires input will have reverted to empty, and no "expires" metatag will be present in the resultant page source

Proposed resolution

Presumably, this is because zero isn't matching the requirements for an otherwise compliant date string.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.26

Component

Views integration

Created by

πŸ‡ΊπŸ‡ΈUnited States msypes

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

Comments & Activities

  • Issue created by @msypes
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Thank you for the bug report.

    Have you tested to see if the problem happens with other metatag forms?

  • πŸ‡ΊπŸ‡ΈUnited States msypes

    No, I did not. I was looking to solve a particular caching issue and tripped over this. I hadn't previously used the module.

  • πŸ‡ΊπŸ‡ΈUnited States Kasey_MK

    Can confirm that the plain value '0' isn't stored on the other metatag forms either (e.g., /admin/config/search/metatag/node). Not only is the metatag <meta http-equiv="Expires" content="0"> not created on the page output, the value isn't stored in the form itself; re-opening the form reveals an empty field.

Production build 0.71.5 2024