- Issue created by @jsidigital
- Status changed to Closed: works as designed
about 1 year ago 7:55pm 28 March 2024 - πΊπΈUnited States DamienMcKenna NH, USA
Metatag generates the output server-side. Part of that is a filter to make sure no unwanted code is added to the output, specifically that no JavaScript is added. So the JavaScript tag you're trying to add is removed when it's building the output.
Even if the JS wasn't removed, this is how it would render:
<meta name="expires" content="<script type="text/javascript"> const now = new Date(); const tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 3, now.getHours(), now.getMinutes(), now.getSeconds()); const rfc1123DateString = tomorrow.toUTCString(); document.write(rfc1123DateString); </script>">
This isn't valid HTML and wouldn't work the way you think it should.
I'm not sure what the correct approach is to get a correct value for the tag, other than maybe to look at a different mechanism, e.g. using page caching and making sure Drupal's Expires HTTP header is correct.