Search code examples
htmlcachingdirectiveboolean-expressionhttp-equiv

HTML: Opposite of http-equiv=expires and http-equiv pragma=no-cache directives


Like many of you, I was seeing and using these two meta tags for years,

<meta http-equiv="expires" content="now">
<meta http-equiv="pragma" content="no-cache">

without much thinking of what exactly they are for, except that they are used to ensure that browser loads new content rather than cached one.

Now I bumped into a client who thinks that horrible performance of his website will be improved by doing the opposite: forcing website to load cached content. Namely, he is sure that it will be much better when we force caching in HTML head.

I have an access only to front end resources. I searched around and haven't found what values would be the opposite of "now" and "no-cache". All searches only return results about how to turn of caching.

Of course, any other ideas to achieve this just within HTML templates are welcome :)


Solution

  • I searched around and haven't found what values would be the opposite of "now" and "no-cache".

    • The opposite of "now" is "2147483648"
    • The opposite of "no-cache" is "only-if-cached"

    Note: The value 2147483648 is here for historical reasons, effectively represents infinity (over 68 years), and does not need to be stored in binary form; an implementation could produce it as a canned string if any overflow occurs, even if the calculations are performed with an arithmetic type incapable of directly representing that number. What matters here is that an overflow be detected and not treated as a negative value in later calculations.

    References