styleguidekit-assets-default icon indicating copy to clipboard operation
styleguidekit-assets-default copied to clipboard

Remove caching meta tags?

Open bradfrost opened this issue 8 years ago • 4 comments

This is probably a question for @EvanLovely, but I'm trying to clean up the UI as much as possible. We currently have this code in the head:

<!-- never cache patterns -->
    <meta http-equiv="cache-control" content="max-age=0" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
    <meta http-equiv="pragma" content="no-cache" />

I believe that was to force the browser to never cache patterns so you always so the latest version. That said, I was wondering if there's another way to accomplish that without these tags? Or if it's necessary at all?

bradfrost avatar Sep 29 '17 19:09 bradfrost

Some interesting results from here: https://stackoverflow.com/questions/1341089/using-meta-tags-to-turn-off-caching-in-all-browsers

The accepted answer (pretty old too) is verbatim to the above, but it looks to not be recommended practice.

In a production environment, I would expect developers to set cache control headers on the web server via .htaccess or an equivalent. Right?

EDIT

Answering your question more specifically, I've never seen BrowserSync have a problem reloading CSS or a pattern, but I don't know if messing with these meta tags would alter that behavior (I'd think not). Something you can certainly try while you are poking around there! 🚧

bmuenzenmeyer avatar Sep 29 '17 19:09 bmuenzenmeyer

Thanks @bmuenzenmeyer!

Fascinating the post is from '09. I wonder how much of it is still relevant, especially considering cross-browser stuff is woven in there. Being that our audience is developers developing locally, it's a safe assumption they're not using IE9 as their primary dev browser.

In a production environment, I would expect developers to set cache control headers on the web server via .htaccess or an equivalent. Right?

Yep, and again I think these tags are more for dev environments where we want to see the latest changes. I think if Browsersync can wrangle that, then we use that instead.

Answering your question more specifically, I've never seen BrowserSync have a problem reloading CSS or a pattern,

That's my experience too!

, but I don't know if messing with these meta tags would alter that behavior (I'd think not). Something you can certainly try while you are poking around there! 🚧

Here's what I'm going to do: I'm going to rip out all the cache-specific meta tags, and if I start seeing issues where things aren't refreshing properly, I'll add them back in one by one, starting with <meta http-equiv="cache-control" content="no-cache" />.

bradfrost avatar Sep 29 '17 21:09 bradfrost

The head looks cleaner now :)

<head>
	<title id="title">Pattern Lab</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width" />
	<link rel="stylesheet" href="styleguide/css/pattern-lab.css" media="all" />
</head>

bradfrost avatar Sep 29 '17 21:09 bradfrost

I think the cacheBuster is all you need!

EvanLovely avatar Oct 16 '17 05:10 EvanLovely