• Resolved Law

    (@laucoste)


    Hi,

    I’d need to set a precise delay for my cache (TTL) using Cloudflare, WP-cloudflare-page-cache, and I also use HTTP Headers (WP plugin).

    => Logged in users must have no cache (so no TTL)
    => Logged out users must have 10 min cache (TTL = 600)

    I see these fields / settings :

    – In Cloudflare : Only “Browser caching TTL” (respect HTTP Header, 30 min, 1 hour, …)
    – In WP-cloudflare-page-cache : ‘Cloudflare Cache-Control max-age’ And ‘Browser Cache-Control max-age’, and Fallback Cache TTL (I activate Fallback).
    – In HTTP Headers, I’ve just set ‘Strict-Transport-Security’ with max-age=63072000; includeSubDomains; preload => so maybe nothing impacting cache.

    At least for the combo WP-cloudflare-page-cache and Cloudflare, could you tell me which value set in those fields ?

    Regards,
    Law

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor iSaumya

    (@isaumya)

    Hi @laucoste,
    First of all, let me fix the terminology error you have made. You see when it comes to caching technology be especially CDN level caching (like Cloudflare or any other CDN) the term that is used to mention how long the cached content will be valid is called max-age or some version of max-age which basically sets the cache time of other things like s-max-age. Anyways so in this question where you say TTL that should be max-age.

    Logged out users must have 10 min cache

    After you install, activate & set up the plugin, if you go under the Cache tab inside the plugin settings, the first two option you will see is as follows:

    Cloudflare Cache-Control max-age
    Browser Cache-Control max-age

    So, basically the first one says for how long your content will be cached on Cloudflare CDN edge servers and the second option says for how long the browser should cache the content so that it doesn’t have to contact Cloudflare server over and over again. Now if anyone refreshes the page before browser cache expires the browser can load the contents very fast from its cache.

    Now in your case, as you want only 10 min cache of your content in Cloudflare CDN server and in your origin server (honestly I don’t know why you wanna do that as this will throw a lot of errors in Google Page speed and other speed testing tool saying you are not caching your content long enough – anyways your site your choice).

    You should set the:

    Cloudflare Cache-Control max-age should be 600.
    Fallback cache TTL should be 600

    A few more note:

    • Once you have set up this plugin you should not change the Browser caching TTL option inside Cloudflare dashboard. It should always be Respect HTTP Header as all the headers are being set by this plugin.
    • I don’t know why you are using HTTP Headers plugins, you definitely don’t need it for HSTS. You can set up HSTS inside Cloudflare dashboard only. You don’t need any plugins for that.
    Thread Starter Law

    (@laucoste)

    Hi @isaumya

    Thanks for your very complete and clear answer. Finally I’ll cache more pages so I’ll let Cloudflare Cache-Control max-age last 1 week. And your Google Page Speed argument convinced me.

    As you evoque the need of HTTP Headers, I’d just need to know – but without going further in the details -, according to you and you great experience of Cloudflare, if these 6 elements in the HTTP Headers are really useful… Or if I can removed all 6 since I use Cloudflare (so it already takes them into account).
    I attached them here :
    – Security (5) : https://imgur.com/a/HgV2Ds1
    – Compression (1) : https://imgur.com/a/GLGB7Hb

    Thanks a lot,
    Regards,
    Law

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @laucoste,
    I hope the screenshots you have shown me are of that HTTP Headers plugins you were using? If so, then yes you don’t need to use that plugin and it is really not good to have a plugin for your HTTP header. In case you see some HTTP headers that you need are not being added by Cloudflare, you can either add them in your server .htaccess file or in nginx.conf file. That is a much better approach.

    Alternatively, if you have good development and coding proficiency you can use the Worker Mode of the plugin which will use Cloudflare workers and then overwrite the default worker code that is provided by this plugin to add your own headers and do many other amazing things. But again overwriting Worker code is a super-advanced thing and not recommended if you don’t know programming and development. In that case, you can always go with .htaccess or nginx.conf depending on what your server stack is.

    P.S.: Setting cache for 1 week will still give Google messages as that is too short of time for cache. The default time set by this plugin is always the best choice as the default has been set keeping a lot of things into consideration.

    • This reply was modified 4 years, 6 months ago by iSaumya.
    Thread Starter Law

    (@laucoste)

    Hi @isaumya

    Yes, the screenshots are from the plugin I use.
    But this plugin does modify the .htaccess file. It just allow to do it from a simpler interface.
    Having no coding competence, I’ll keep on like that.

    Thanks again for your help,
    Regards,
    Law

    Thread Starter Law

    (@laucoste)

    Last thing please @isaumya

    P.S.: Setting cache for 1 week will still give Google messages as that is too short of time for cache. The default time set by this plugin is always the best choice as the default has been set keeping a lot of things into consideration.

    I’ve erased default value so what were these values for Cloudflare Cache-Control max-age and Browser Cache-Control max-age ?
    When you say 1 week (604 800) is too short, which of the 2 values are you talking about ?

    Thanks,
    Regards,
    Law

    Plugin Contributor iSaumya

    (@isaumya)

    Hi @laucoste,
    Sorry, my bad. You can keep it to 1 week. I’m sorry. I would recommend you to stick to the default settings: https://i.imgur.com/LCf7tmE.png

    Thread Starter Law

    (@laucoste)

    Perfect, thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Define a precise TTL’ is closed to new replies.