website icon indicating copy to clipboard operation
website copied to clipboard

Browser caching on Chrome breaks website

Open jepotter1-archive opened this issue 7 years ago • 9 comments

Looks like Chrome is caching the CSS/JS and it is not being updated when the website is updated. I would recommend cache fingerprinting (use main.0fklh924sd834.css instead of main.css).


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

jepotter1-archive avatar Oct 20 '18 23:10 jepotter1-archive

We would need to create a manifest file, use PHP to read that file on every page render, and rewrite the script tags. Ideally we would do this with all assets. In general, this is kinda a pain to do with what we are currently using. I would love to see most of this site go JavaScript with a build step that handles all of this for us.

btkostner avatar Oct 21 '18 01:10 btkostner

I am trying to create a PR for this. On the PHP end we could make a function like get_asset, which takes the asset name and adds the MD5 hash to it (in: main.js, out: main.398f9df83.js). On the JS end we could add (or write, it's not that hard) a Gulp plugin that renames all the assets by appending the hash. Then we would just need to replace all the <script>, <img> & <link> tags with <?php get_asset ?> calls.

This is pretty much how Django/Rails handles it.

jepotter1-archive avatar Oct 23 '18 03:10 jepotter1-archive

Seeing as we already use per-page CSS and JS through a section of PHP, this shouldn't actually be that hard. See https://www.alainschlesser.com/bust-cache-content-hash/

lewisgoddard avatar Oct 25 '19 23:10 lewisgoddard

Moving to High priority as we are getting browser script caching errors that prevent people from buying elementary.

btkostner avatar Nov 06 '19 17:11 btkostner

CSS is all built in Gulp but JS is webpack. This might need two separate manifests, although the PHP should be able to handle that automatically with one function.

lewisgoddard avatar Nov 09 '19 03:11 lewisgoddard

I cannot figure out why cache busting does not seem to work for CSS in Gulp. I could rework the CSS to also be done by webpack and it would leverage the same approach, but I wanted to check before I change the whole build process.

RMcNeely avatar Dec 13 '19 06:12 RMcNeely

CSS moving to webpack would be fine so long as we had feature parity.

lewisgoddard avatar Dec 14 '19 21:12 lewisgoddard

Any objections to updating to Webpack 4?

On Sat, Dec 14, 2019, 4:13 PM Lewis Goddard [email protected] wrote:

CSS moving to webpack would be fine so long as we had feature parity.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/elementary/website/issues/2093?email_source=notifications&email_token=AAVNEHWQFIZZRYE6HXBWWQ3QYVEBDA5CNFSM4F6IXUT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4LPMQ#issuecomment-565753778, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVNEHXMETH42JC4ZPEQDITQYVEBDANCNFSM4F6IXUTQ .

RMcNeely avatar Dec 14 '19 21:12 RMcNeely

@RMcNeely nope!

btkostner avatar Dec 15 '19 00:12 btkostner