Bypass Cloudflare Cache on Joomla Cookie

Discussion regarding Joomla! 3.x Performance issues.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
goble
Joomla! Explorer
Joomla! Explorer
Posts: 269
Joined: Sat Jan 09, 2010 11:23 am

Bypass Cloudflare Cache on Joomla Cookie

Post by goble » Sat Jul 02, 2022 12:42 pm

I need to create a "worker" for my Joomla 3 Site in order to bypass Cloudflare Cache based on joomla cookies.

Here's one which is made for WordPress : https://github.com/pmeenan/cf-workers/t ... -on-cookie

Here's what I get when I login on my joomla front-end:

https://imgur.com/a/IL8lAly
Last edited by toivo on Mon Jul 04, 2022 10:10 pm, edited 1 time in total.
Reason: mod note: moved from 3.x Coding
Mauritius Travel Guide https://explora.mu

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30924
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Bypass Cloudflare Cache on Joomla Cookie

Post by Per Yngve Berg » Sat Jul 02, 2022 2:27 pm

What are you using as session storage (file, database or Memcached/Redis)?

goble
Joomla! Explorer
Joomla! Explorer
Posts: 269
Joined: Sat Jan 09, 2010 11:23 am

Re: Bypass Cloudflare Cache on Joomla Cookie

Post by goble » Sun Jul 03, 2022 6:06 am

Hello Per and thanks for your help.

Am not sure how to answer you question. The website explora.mu is using basic Cloudflare settings.

In Joomla > System
> Session Settings
Session Handler : Database
Session Lifetime : 20
Shared Sessions : No
> Cache settings
Cache Handler : File
Path to Cache Folder :
Cache Time : 15
Platform Specific Caching : No
System Cache : Off Caching disabled
Mauritius Travel Guide https://explora.mu

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 30924
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Bypass Cloudflare Cache on Joomla Cookie

Post by Per Yngve Berg » Sun Jul 03, 2022 9:48 am

Your sessions is stored in the database. For better performance, let php handle the session by setting Session Handler "filesystem"

goble
Joomla! Explorer
Joomla! Explorer
Posts: 269
Joined: Sat Jan 09, 2010 11:23 am

Re: Bypass Cloudflare Cache on Joomla Cookie

Post by goble » Mon Jul 04, 2022 7:33 am

Hello and thanks,

by setting "session handler" to php, I get better performance as per GTmetrix (even though the site stays in Grade C)

However my goal is to use cloudflare to reach Grade A. If I follow the instructions in the following link
https://www.digitalkube.com/reduce-cloudflare-ttfb/, this goal is reached perfectly but it doesn't work well when users have to login (so I had to remove these settings in cloudflare).

A workaround is to use the above CF settings and use a worker but am really bad in coding. A ready-made code is available for WordPress and I was told that I could adapt it to work with Joomla by identifying the joomla cookies.

Here's the one which is made for WordPress "Bypass Cache on Cookie" : https://github.com/pmeenan/cf-workers/t ... -on-cookie

Here's what I get when I login on my joomla front-end:
https://imgur.com/a/IL8lAly

I guess I need to amend 2 things :
1. Change the cookie prefixes for those of my joomla site (here is where I need help)
2.Change wp-admin to administrator to bypass cache for joomla admin

Code: Select all

// Cookie prefixes that cause a request to bypass the cache when present.
const BYPASS_COOKIE_PREFIXES = [
  "wp-",
  "wordpress",
  "comment_",
  "woocommerce_"
];

// URL paths to bypass the cache (each pattern is a regex) 
const BYPASS_URL_PATTERNS = [
  /\/wp-admin\/.*/
];
Mauritius Travel Guide https://explora.mu


Locked

Return to “Performance - Joomla! 3.x”