Get the most out of your Centmin Mod LEMP stack
Become a Member

Cloudflare Cloudflare not caching images & Polish not working

Discussion in 'Web Development & Web Performance' started by Rake-GH, May 26, 2021.

  1. Rake-GH

    Rake-GH Active Member

    177
    90
    28
    Jul 29, 2019
    USA
    Ratings:
    +139
    Local Time:
    9:24 PM
    default
    default
    I had some questions regarding images not being cached by CF and some Polish confusion, and I figured this is the best place to ask.


    I was just poking around in Cloudflare and noticed this:
    upload_2021-5-25_16-14-7.png
    I thought it was weird that these are being served by the origin, even weirder that the content type is empty.

    Then I realized, 99% of my images on the site are all attachments. None of the attachments are being served as webp despite using Polish? Yikes, how did I never realize this before.

    I found this: Getting proxy images to work well with CloudFlare compression (Polish) and this Getting proxy images to work well with CloudFlare compression (Polish)

    There doesn't seem to be any simple way to solve this problem.

    Any thoughts or advice? Thank you in advance
     
  2. Rake-GH

    Rake-GH Active Member

    177
    90
    28
    Jul 29, 2019
    USA
    Ratings:
    +139
    Local Time:
    9:24 PM
    default
    default
    I was just thinking, I can probably cache the image attachments on the CDN at least by making a page rule, something like:

    if uri.contains(/attachments/*-png.*) then cacheLevel = standard

    does that sound like a decent idea?
     
  3. rdan

    rdan Premium Member Premium Member

    5,235
    1,307
    113
    May 25, 2014
    Ratings:
    +2,012
    Local Time:
    9:24 AM
    Mainline
    10.2
    That's the right thing to do, Yes.
     
  4. rdan

    rdan Premium Member Premium Member

    5,235
    1,307
    113
    May 25, 2014
    Ratings:
    +2,012
    Local Time:
    9:24 AM
    Mainline
    10.2
    Mine

    upload_2021-5-26_5-7-8.png
     
  5. eva2000

    eva2000 Administrator Staff Member

    48,517
    11,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,304
    Local Time:
    11:24 AM
    Nginx 1.21.x
    MariaDB 10.x
    Yup @rdan approach would be the easiest via a custom Cloudflare page rule :)
     
  6. Rake-GH

    Rake-GH Active Member

    177
    90
    28
    Jul 29, 2019
    USA
    Ratings:
    +139
    Local Time:
    9:24 PM
    default
    default
    I just wanted to note that this firewall rule makes paid account upgrades fail on my website:
    upload_2022-1-16_22-4-26.png

    So if you ever run into trouble with registrations, try disabling this rule.

    Sounds crazy, but it's true, hope it helps someone so they don't have to debug as long as I did to find the problem
     
  7. eva2000

    eva2000 Administrator Staff Member

    48,517
    11,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,304
    Local Time:
    11:24 AM
    Nginx 1.21.x
    MariaDB 10.x
    CF Firewall rule or Page rule? That looks like CF Page rule to me.
     
  8. Rake-GH

    Rake-GH Active Member

    177
    90
    28
    Jul 29, 2019
    USA
    Ratings:
    +139
    Local Time:
    9:24 PM
    default
    default
    Page rule, that was a typo
     
  9. eva2000

    eva2000 Administrator Staff Member

    48,517
    11,114
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +17,304
    Local Time:
    11:24 AM
    Nginx 1.21.x
    MariaDB 10.x
    I see, still don't see how css.php caching prevented user upgrades though. What errors did you get with that Page rule in place?