retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.02k stars 201 forks source link

Cache Clarification? #563

Closed latenitefilms closed 1 year ago

latenitefilms commented 1 year ago

I just noticed this in my websites code:

<meta name="turbo-cache-control" content="no-cache" data-turbo-track="reload" data-track-token="3.0.1.738976285563">

What does it actually do?

One thing I've noticed when testing my site with GTmetrix is that it suggests "Serve static assets with an efficient cache policy". Is this something I can tweak with Retype?

image

Also, whilst I've got you... it would be amazing if something could be added to the documentation under hosting to explain the pro's and con's between GitHub Pages vs Docker vs Cloudflare vs Netlify.

Would there be big performance improvements moving from GitHub Pages to Cloudflare, for example?

geoffreymcgill commented 1 year ago

One thing I've noticed when testing my site with GTmetrix is that it suggests "Serve static assets with an efficient cache policy". Is this something I can tweak with Retype?

Unfortunately, this is a web server setting and not something that Retype can adjust in the static files.

The short expiry cache policy is an issue with GitHub Pages where they set files to expire in 10 minutes by default by setting the CacheControl: max-age=600 header (600 seconds). Others have run into the same issue with GitHub Pages, see

https://webapps.stackexchange.com/questions/119286/caching-assets-in-website-served-from-github-pages https://github.com/orgs/community/discussions/11884

This is also exactly the reason why we just moved retype.com from GitHub. Currently, the site is hosted on Netlify, although I see cache-control: public, max-age=0, must-revalidate in the response headers, so I'm not sure what's up with that. The current GTmetrix score is better now though: https://gtmetrix.com/reports/retype.com/DTqqXoLW/.

Screen Shot 2023-06-02 at 12 13 41 PM

I think I also enabled the Proxied status on the Cloudflare DNS config, so they might be fidgeting with the cache headers now.

GitHub Pages, Netlify, and Cloudflare Pages are all excellent and essentially provide the same service. They all require very minimal setup and automatically push updates to you update your GitHub repository, if you are using the Retype GitHub Build Action.

I suspect you would not actually notice much of a performance difference if moving from one service to another, but those performance report services like GTmetrix do report better scores if using Netlify or Cloudflare Pages. My guess is Cloudflare Pages will give the best performance, but that is just a guess.

Also, whilst I've got you... it would be amazing if something could be added to the documentation under hosting to explain the pro's and con's between GitHub Pages vs Docker vs Cloudflare vs Netlify.

Writing up a deep dive comparison into hosting options is a good idea and I'll try to put a document together.

Hope this helps.

latenitefilms commented 1 year ago

I just tried turning on the free CloudFlare service for https://fcp.cafe, to see if that makes any difference.

BEFORE:

image

AFTER:

image

...so, not really much of a difference, at least not in that specific test.

From an end-user perspective though, site feels very fast.

Thanks again for the detailed reply!

geoffreymcgill commented 1 year ago

If you are GitHub Pages and Cloudflare for your DNS, the following setting might help:

Screen Shot 2023-06-02 at 1 40 55 PM
latenitefilms commented 1 year ago

You're an absolute legend @geoffreymcgill - thank you! You're awesome.

image image