Get a free advice now!

    Pick the topic

    Developer OutsourcingWeb developingApp developingDigital MarketingeCommerce systemseEntertainment systems

    Thank you for your message. It has been sent.

    Tags

    Testing Cloudflare – bypassing cache

    Testing Cloudflare – bypassing cache

    Cloudflare is a really amazing tool. By changing your DNS settings to point to CF servers and enabling static caching, your page will be loading much faster, using less server bandwidth and the TTFB (time-to-first-byte) will improve.

    In this article, we will find a solution for disabling CloudFlare caching directly from your browser. It’s a handy trick for testing.

    Automatic Platform Optimization for WordPress

    APO (Automatic Platform Optimization) allows Cloudflare to serve a WP site from its edge network. Edge servers store (cache) content in strategic locations in order to take the load of the origin server.

    By moving static assets like images, as well as HTML and JavaScript files as close as possible to the requesting client computer, an edge server cache is able to reduce the amount of time it takes for a web resource to load.

    Enabling an API in WordPress can be done in 3 steps: Confirm DNS Records, Change nameservers and activate the Cloudflare WordPress plugin.

    cf-cache-status

    How to know if CloufFlare is working? You can feel that website is loading faster, but to be sure that traffic is handled from CF, we can inspect page Response Headers. Browser Developer Tool / Network – filter ‘Doc’ type – and then Headers Tab.

    The parameter cf-cache-status set to HIT means that cache is working and we’re connecting directly to the CloudFlare server to get the HTML of the site.

    Dynamic elements caching

    When configuring CloudFlare cache, it is important to understand that page contents will be cached as static. All dynamic elements that previously relied on using backend rendering (without Client side javascript rendering) will stop working or will return the old state (example: data from 1 hour ago, instead of live).

    We have enabled caching in the CF panel, and we would now like to test our website. Some components are easy to test, we can see immediately that data is outdated and the component should be rewritten to use client-side rendering.  However, sometimes we’re not sure how a website should look like (without cache enabled).

    Turn off caching

    One method to disable caching is to turn it off in the Cloud Flare panel. However, we need to wait for propagation changes and this setting will impact all site visitors. In addition, our browser cache / windows DNS cache can still serve us the old (cached) website version. Not really a comfortable way of testing.

    Bypassing CF cache

    The developer tool (Developer console) in Chrome Browser provides a checkbox for disabling cache. When checked, it ignores cached website versions and getting live HTML from the origin server.

    The solution to bypass Cloudflare cache is to check “Disable cache” (Network Tab), keep DevTools open and refresh the page. When Checking Response Headers we’re seeing: cf-cache-status: BYPASS. So, we’re seeing original page contents without static cache.

    It’s a really useful trick when testing dynamic components or just testing if CF doesn’t cache too much on our website.

    disable cache at browser network tab

    That’s it for today’s guidelines. Make sure to follow us for other useful tips, and don’t forget to subscribe to our newsletter.

    Comments
    0 response

    Add comment

    Your email address will not be published. Required fields are marked *

    Popular news

    A game changer for WooCommerce users
    • Our Highlights

    A game changer for WooCommerce users

    March 24, 2023 by createIT
    The differences between a web app and a mobile app
    • Services
    • Technology
    • Trends

    The differences between a web app and a mobile app

    March 7, 2023 by createIT
    Webrooming and showrooming
    • Trends

    Webrooming and showrooming

    February 14, 2023 by createIT
    PHPStorm – fix long load time of a directory window
    • Dev Tips and Tricks

    PHPStorm – fix long load time of a directory window

    January 20, 2023 by createIT
    reCAPTCHA v3 – WordPress implementation
    • Dev Tips and Tricks

    reCAPTCHA v3 – WordPress implementation

    January 20, 2023 by createIT
    How to compare GIT and server files
    • Dev Tips and Tricks

    How to compare GIT and server files

    January 19, 2023 by createIT
    How to trigger a click event inside iframe?
    • Dev Tips and Tricks

    How to trigger a click event inside iframe?

    January 19, 2023 by createIT
    FOOEvents – generate a custom CSV report
    • Dev Tips and Tricks

    FOOEvents – generate a custom CSV report

    January 19, 2023 by createIT
    Headless chrome – testing webgl using playwright
    • Dev Tips and Tricks

    Headless chrome – testing webgl using playwright

    January 18, 2023 by createIT
    Preview big SQL files with PilotEdit
    • Dev Tips and Tricks

    Preview big SQL files with PilotEdit

    January 18, 2023 by createIT

    Support – Tips and Tricks
    All tips in one place, and the database keeps growing. Stay up to date and optimize your work!

    Contact us