I've a static website hosted on GitHub pages: why does Cloudflare only cache a small percentage of it?

cdn
cache
#1

Hi everyone,

I’m hosting my website (it’s static HTML, CSS etc…) on GitHub pages and I’ve put CloudFlare in front of it.

I don’t update it very often (probably less than 4-5 times per month).

Being all static pages, I would expect it to be served from CloudFlare CDN/cache most of the time, instead only a few requests are being served by CloudFlare and all the rest is hitting GitHub Pages.

Note: I’m far from hitting the limit (100 GB/month) offered by GitHub, but I would like to understand what I’m doing wrong.

I’m attaching a picture so you can see what I see in the dashboard.

Any clue on what could cause this? Thanks

0 Likes

#2

This is usually caused by the actual Cache-Control headers, maybe GitHub forces low expiration on resources or even forces no-cache on something.

Have you enabled Cache Everything on Cloudflare via Page Rules?

0 Likes

#3

Hi Matteo, thanks for your reply!

In Page Rules I only have this:

I only have 1 rule left, how could I use it to “Cache Everything” ? If you can please point me to a tutorial I will see what I can do.

Thank you again! Cheers

0 Likes

#4

Hi!

The first rule is kinda fine, but I would remove the https in front and make it universal, it changes nothing in the actual work it does. It doesn’t redirect subpaths though. Add an * at the end of the source and a $1 at the end of the destination.

The second rule is not needed, remove it and enable the domain wide rule under Crypto (unless this path is the only one you want with HTTPS, but I doubt that).

Then add a new rule, matching the same as the first, adding a Cache rule of Cache Everything.

0 Likes

#5

Thanks again, I’ve a small problem:

  1. I’ve enabled the SSL “domain wide rule” under Crypto as you said: all fine
  2. I’ve removed the second rule as you said: all fine
  3. I’ve changed the first rule and not it’s:

but when I add the new rule, matching the same as the first, I get this error:

I’m sure I misunderstood something here…

0 Likes

#6

Not sure if it’s the same thing (or if I’m leaving something out), but this one worked:

I basically added www. in front of andreagrandi.it

0 Likes

#7

Yeah, that was the right solution!

1 Like

#8

Thank you so much! :slight_smile:
Now I will check it back in few days to see if it had any effect (I hope so!).

Cheers

1 Like

#9

@Matteo mentioned the caching headers, but if you add Edge Cache TTL to the Page Rule, you’ll have some control over how long your resources stay in the Cloudflare cache. You said you only update a few times per month, so you might want to set Edge Cache to 2-3 days or whatever best suits your use case.

1 Like

#10

Thanks! I will definitely try this too if things shouldn’t change in the next days.

1 Like

closed #11

This topic was automatically closed after 30 days. New replies are no longer allowed.

0 Likes