I cannot seem to cache images for my subdomain

I cannot get the images to be cached on my subdomain; there is no cf-cache-status in the header.
I can’t tell if anything is working to speed up my (very slow) site. I set up cloudflare at the main domain (grandten.com) but am testing a subdomain (test.grandten.com). How can I get it to cache images for that subdomain?

I see the cache-control: max-age=0, but I set up my page rules as:
https://test.grandten.com/
Cache Level: Cache Everything, Edge Cache TTL: 7 days”

You are just using Cloudflares Nameservers, but you are not proxying (:orange:) any of these two domains. They ATM are all in “DNS Only Mode” (:grey:).

To change that, please log in into your Cloudflare Dashboard and navigate to the DNS section.
Switch both domains from :grey: to :orange: and wait until it has propagated.

Ah-ha! I am hoping it’s something simple and dumb that I missed! THANK YOU!
I made the change and now see the CDN is working.

However, I’m still seeing that many images are not cached. There is a max-age=0 for these, and I don’t know where that is getting set (or if that’s even the issue).
https://www.webpagetest.org/performance_optimization.php?test=210613_BiDcRR_4f852762763ec1d9c185987157761d19&run=1#cache_static_content

Please set a PageRule with a pattern that matches all of your images and set:

Browser Cache TTL: 1 year

This will make this problem vanish. Or if you want to set it globaly for the domain you can natigate to Cache ==> Configuration and set Browser Cache TTL to 1y:

Keep in mind that depending on your setup/CMS you should choose a time that will fit your needs. But for static assets 1y actually is recommended.

Thanks again. I think with these corrected settings, the site is being loaded as quickly as can be expected (with the shared server I’m using). I really appreciate you taking the time to actually look at the site and make these recommendations. The Cloudflare support team just sent me links to irrelevant documentation. THANK YOU.

2 Likes

Your site will not be “faster” in general with a higher TTL, but it is more optimized as it does not force recurring visitors to load things again and again if they still have them in local cache.

You are welcome! The community is the right place for such requests anyway.
If you are open to more recommendations which actually make your site faster, here are some:

  • combine these CSS files into at least 2 files:

    1. critical CSS
    1. rest
      I always recommend this even if most people/sites recommend against this! Why do i do so? With HTTP3 you do not profit from shrinking your requests to as few requests as possible, but if you do you anyway do not have ANY negative impact, but one big other benefit: compression kicks way more in few big files then in a lot of small files. Thats my I recommend it.
  • preload critical CSS and important files

  • combine JS aswell for compression.

  • use WEBP for Logo. You ATM use a PNG format. If possible use a SVG, thats what I recommend

  • work with passive JS eventlistener instead of diretly executed JS functions

  • dont use old PHP 5.6.40 unless you really do have a good reason for. Its not just all about static content but on a commercial page the checkout and the login must be fast. If possible please switch to
    a. PHP 7.4
    b. PHP 8.0 (if possible and compatible)

1 Like

I welcome any and all suggestions! I actually built a new version of the site at test.grandten.com, and am hoping to push it live soon.
That should be running off php 7.4. I used MultiPHPManager to update php for this test subdomain only.

Good call on the logo - will turn that into a svg now.

Since I’m more of a site admin than a developer, I’m not entirely sure how to combine and preload css files like you’re suggesting. I have these settings turned on in Cloudflare, but that’s probably a more general thing. I’ll look for plugins that might do what you’re describing.

Thank you again.

Very good, can confirm I see the new PHP version. Even if that often helps to debug things, visitors dont need to see which PHP version your running on. See if you can set expose_php = Off in your php.ini or even global.

Thats a good idea, always make sure it in the end is smaller then before and please optimize your logo before impelementing it. Also you can now place it inline which saves a request. But please just do it if you reuse it or if it is not bigger then 5kb.

As you run on Wordpress there are plenty of plugins that do this, WP-Rocket is one I for sure know does it. But as I am not a Wordpress user myself I am not a big help here.

These settings will make sure your content (on file(URL base) will be optimized & compresses, but they do not combine/concatenate your files as this would require altering the DOM and is out of scope for this feature Cloudflare offers.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.