Advertisement

Varnish, NGINX & Joomla 5

Discussion regarding Joomla! 5.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.
Post Reply
User avatar
stormbyte
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Tue Mar 03, 2015 1:16 pm
Location: paris
Contact:

Varnish, NGINX & Joomla 5

Post by stormbyte » Fri Dec 06, 2024 10:52 am

Dear all,

I don't many threads regarding optimisation using Varnish. :(
From my side I developped a VCL only to cache static elements, a FastCGI Cache on NGINX to speedup page generation but that's all. I disabled JCH Optimize (even 9), deleted SpeedCache, and so on.

Using Varnish with static elements, a 2Gb FastCGI cache and dedicated server is giving better results than JCH or SpeedCache, and best of all is generating a new page content for each request.

But I know well there's a better approach, but I was unable to integrate it even spending hours with efforts on...
This is caching all pages generated from FastCGI and keeping them into Varnish cache.
The problem is clear: JOOMLA is generating a cookie even for visitor ... and that's the problem because each same static page is seen as a new request, not cached....

Guyz, anybody tried and success to cache HTML pages from FastCGI to Varnish?

What's the best approach (due to cookies?) ! Please share you toughts, ideads, code, whatever! :)
Thx


NB: I know before Joomla5 there was no such cookie. so not so complicated. I don't want to change the core Joomla, just to find a clear and professional approach to solve this link btw Varnish & Joomla 5 :)
Kind Regards, Committed to Joomla and professional cybersecurity!
Cybersecurity Services: https://www.akaoma.com - Protect your business from cyber threats
CVE Vulnerabilities: https://cve.akaoma.com - Real-time Joomla vulnerability tracking

Advertisement
User avatar
stormbyte
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Tue Mar 03, 2015 1:16 pm
Location: paris
Contact:

Re: Varnish, NGINX & Joomla 5

Post by stormbyte » Wed Jan 22, 2025 8:28 am

OK not sure this topic is attracting people ;)

Nobody is using varnish AND joomla together ??? Weird!

FastCGI cache is definitely great for accelerating page generation process, but for full HTML generated page it may be clearly interesting to avoid backend joomla request and throw directly pages from Varnish ...
At this time I'm caching pages from many other cools & systems BUT joomla and it's automatic cookie generation (even not authenticated) is a problem IMY. Any tips?
Kind Regards, Committed to Joomla and professional cybersecurity!
Cybersecurity Services: https://www.akaoma.com - Protect your business from cyber threats
CVE Vulnerabilities: https://cve.akaoma.com - Real-time Joomla vulnerability tracking

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 25403
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Varnish, NGINX & Joomla 5

Post by pe7er » Wed Jan 22, 2025 9:00 am

stormbyte wrote: Wed Jan 22, 2025 8:28 amNobody is using varnish AND joomla together ??? Weird!
I've used Varnish Cache in the past in a Joomla 3 website. We had some issues with:
- Logged in users and caching user data and displaying it to other users
- Emptying cache

However, these issues might have been caused by mistakes in our configuration. ;D
Due to these problems, we decided to switch to Redis cache instead, which worked better in our case.
Kind Regards,
Peter Martin, Global Moderator + Joomla 5.2 Release Manager
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

User avatar
stormbyte
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Tue Mar 03, 2015 1:16 pm
Location: paris
Contact:

Re: Varnish, NGINX & Joomla 5

Post by stormbyte » Wed Jan 22, 2025 10:11 am

Hi Peter!
Thanks for your feedback. But Redis cache is only for session, I mean here Varnish is caching the full HTML webpage rendered by joomla!

But for sure for logged in users it's a pain, I think there's no real solution at all using Varnish for logged users it's better to use JCH or SpeedCache or whatever, Joomla side only.

But I'm searching for guest users ONLY (ready to cache same content for everybody!) but the visitor cookie is still generated by Joomla...
Kind Regards, Committed to Joomla and professional cybersecurity!
Cybersecurity Services: https://www.akaoma.com - Protect your business from cyber threats
CVE Vulnerabilities: https://cve.akaoma.com - Real-time Joomla vulnerability tracking

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 25403
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Varnish, NGINX & Joomla 5

Post by pe7er » Wed Jan 22, 2025 10:24 am

Ok! If you want HTML webpage cache for guest users only,
why don't you just choose Joomla's core plugin System - Page Cache ?
Kind Regards,
Peter Martin, Global Moderator + Joomla 5.2 Release Manager
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

User avatar
stormbyte
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Tue Mar 03, 2015 1:16 pm
Location: paris
Contact:

Re: Varnish, NGINX & Joomla 5

Post by stormbyte » Wed Jan 22, 2025 10:37 am

When a user makes a request with 'System Page cache' , the request goes from:
client --> varnish (not cached) --> Nginx (FastCGI PHP Cache) --> Joomla/System Page Cache
then goes back to the user using the reverse side.

Rendering process is faster with "System Page" (using already cached elements from page,modules,etc) BUT from my own tests I removed JCH/SpeedCache/Page Cache and put a FastCGICache PHP Cache (everything in RAM virtual drive) in NGINX and rendering page is FASTER then being managed from Joomla. Weird, but real.

Page Cache is not activating a way to catch those elements inside the Varnish :(
They're present in cache but in the Joomla backend.

I want to find a way to deliver HTML from 1st tech element only: Varnish ;)
Kind Regards, Committed to Joomla and professional cybersecurity!
Cybersecurity Services: https://www.akaoma.com - Protect your business from cyber threats
CVE Vulnerabilities: https://cve.akaoma.com - Real-time Joomla vulnerability tracking

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1450
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

Re: Varnish, NGINX & Joomla 5

Post by stutteringp0et » Thu Mar 06, 2025 8:39 pm

I use varnish with Joomla on all of my sites.

The trick is coming up with a list of pages NOT to cache and let it do its thing.

I keep login pages to a minimum (because they cannot be cached and still work), then i have a special rule looking for the logged in cookie, which disables caching for that user.

I think I'll write up an article describing the necessary configs.
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.

User avatar
stutteringp0et
Joomla! Ace
Joomla! Ace
Posts: 1450
Joined: Sat Oct 28, 2006 11:16 pm
Location: Texas
Contact:

Re: Varnish, NGINX & Joomla 5

Post by stutteringp0et » Wed Mar 19, 2025 6:49 am

I actually just found a better way to use Varnish with Joomla. It takes a bit of work within Joomla by way of my System - Expires Headers plugin.

Instead of coming up with a list of URLs for Varnish to ignore (you still should do it for /administrator and option=com_ajax), I set up the Expires Headers plugin to send no-cache no-store and must-revalidate, and Varnish ignores those pages.

It's lightning fast for cached pages and I don't have to manually update ignore lists in the vcl.

Before someone accuses me of hawking my extensions, all of my extensions are free.
My extensions: http://extensions.joomla.org/profile/pr ... ails/18398
Honk if this signature offends you.

Advertisement

Post Reply

Return to “Performance - Joomla! 5.x”