pattern-lab / styleguidekit-assets-default

The static assets for the default StyleguideKit for Pattern Lab. Contains styles and mark-up for Pattern Lab's front-end.
http://patternlab.io/
MIT License
35 stars 67 forks source link

Remove caching meta tags? #74

Open bradfrost opened 6 years ago

bradfrost commented 6 years ago

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?

bmuenzenmeyer commented 6 years ago

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! 🚧

bradfrost commented 6 years ago

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 commented 6 years ago

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>
EvanLovely commented 6 years ago

I think the cacheBuster is all you need!