Search
Other Cache Cleaner questions
Forum

Major problems with cache on SiteGround hosting.

Dave Bishop's Avatar Dave Bishop
Hi Peter, they figured out the issue. Can this be fixed? We'd be very grateful.

I took the time to carefully review the case in details. The cache purge request generated by the Regular Labs Cache Cleaner plugin fail, due to the recent security updates we introduced to our system. We no longer allow purge requests form hosts different than the localhost - 127.0.0.1. The security of our clients has always been an important part of our web hosting services and we are dedicating a lot of time and resources on constantly improving it. The new security updates aim to further tighten up the security of our hosting infrastructure and prevent any unwanted malicious activity towards the server.

Currently our system will reject anything that comes from an external request:
local@ [ ~]  [b]curl -sX PURGE -D - https://lmbo.org/[/b]
[b]HTTP/2 403[/b]
server: nginx
date: Tue, 28 Mar 2023 16:10:56 GMT
content-type: text/html
content-length: 52
vary: Accept-Encoding
etag: "63fc86b6-34"
host-header: 8441280b0c35cbc1147f8ba998a563a7
x-proxy-cache-info: DT:1
 
[b]403 - Forbidden | Access to this page is forbidden.[/b]

The Regular Labs Cache Cleaner plugin attempts to flush the server cache using the PHP code in the following file: ./plugins/system/cachecleaner/src/Cache/SiteGround.php, however as the request generated by the plugin doesn't originate from the localhost our system rejects them.

In order to successfully purge the server side cache using HTTP request, the requests needs to originate from the server and target the localhost(127.0.0.1). Here is an example with cURL:
@giowm1131.siteground.biz:~/
[b]curl -sX PURGE http://127.0.0.1/ -H "Host:lmbo.org"[/b]
[b]Successful purge[/b]Successful purgeKey : httplmbo.org/

Please forward this information to the plugin developer. As soon as the PHP code in: ./plugins/system/cachecleaner/src/Cache/SiteGround.php is modified to accommodate the new server changes, the cache purging functionality for our hosting environment should start working again.
Joris Lange's Avatar Joris Lange
Would be nice indeed if this would work again...
Peter van Westen's Avatar Peter van Westen ADMIN
Not sure if this will fix it, but please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
Hi Peter, I am still getting the error. I manually cleared the cache on SG as well.

Do you want me to have them check it again?
Peter van Westen's Avatar Peter van Westen ADMIN
Can you give me (super) admin and (s)ftp access so I can take a look?
You can use the 'Confidential information' button in the forum editor to hide sensitive information.
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
Of course

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
TheSiteground code (taken from their old plugin) uses fsockopen and fwrite to call a PURGE or BAN thing.

Changing the URL in that statement still doesn't work:
PURGE http://127.0.0.1/(.*) HTTP/1.0
Host: lmbo.org
Connection: Close
Or even:
PURGE http://127.0.0.1/ HTTP/1.0
Host: lmbo.org
Connection: Close

It will respond with: "HTTP/1.1 301 Moved Permanently"

So if Siteground can provide you with the full PHP code to do this (either via fwrite or curl), then I might be able to get it to work.
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
I'll pass that along to them.

Thank you
Dave Bishop's Avatar Dave Bishop
Here is their response.

Judging by the response: "HTTP/1.1 301 Moved Permanently" the request most likely targets incorrect domain:
@giowm1131.siteground.biz:~/www/[b]lmbo.org[/b]/public_html$ curl -sX PURGE http://127.0.0.1/ -H [b]"Host:wrongdomain.com"[/b]
 
[b]301 Moved Permanently[/b]
 
301 Moved Permanently
nginx
 
 

The request needs to target the correct host/domain - in your case lmbo.org, otherwise it will fail.

Other alternative is for the developer to use shell_exec to flush the cache, instead sending HTTP request. I ran few tests on my personal website and I was able to successfully flush the server cache using PHP script with shell_exec and a simple cURL:
https://www.php.net/manual/en/function.shell-exec.php

Here is the output of the test script when I access it from my local machine:
local@ [ ~]  curl [b]https://tsvetanmitev.com/test.php[/b]
[b]Successful purge[/b]Successful purgeKey : httptsvetanmitev.com/ local@ [ ~]

However, I am afraid that I cannot provide you with guidance what and how the current plugin code should be modified in order to accommodate the new server changes. As a technical support team we specialize in supporting our hosting environment and products. Developing code for 3rd party software is beyond our scope of support and expertise.
Peter van Westen's Avatar Peter van Westen ADMIN
Response is pretty useless.
It does not address the fsockopen/fwrite thing, which is using the correct host.
So they changed something to make that stop working.

Also weird that he pretty much says:
I have a working PHP file here, than contains code that could/should be used... but I am not going to tell you what it is. Instead, I'll spend time on a longer paragraph telling you that I am not going to give it.
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
Hi Peter, did you upload a new development release? It says it's 23 hours old.
Peter van Westen's Avatar Peter van Westen ADMIN
Sorry, should be updated now...
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
YES it works! At least I get no error message. You are a the best Peter! One of Joomla's heros.

Thank you so much!

Dave
Peter van Westen's Avatar Peter van Westen ADMIN
?
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
Hi Peter, I am not getting the error anymore but don't think the cache is being cleared. I only see a message saying Cache cleaned (142 bytes)

I asked SG to check if the cache is being cleaned and they said it's not.

When I press the "Clean Cache" option in the backend of your site I see the following request in the access log:

127.0.0.1 lmbo.org - [02/Apr/2023:18:00:56 +0000] "PURGE / HTTP/1.1" 200 154 "-" "curl/7.85.0" | - | - - 0.000 - 0 NC:000000 UP:-DT


This does not clean your cache, because when I test the following resource with a curl I get a "HIT", meaning there is a cached resource:

$ curl -sILX GET lmbo.org/media/vendor/fontawesome-free/w.../fa-brands-400.woff2 | grep x-proxy-cache
x-proxy-cache: HIT



When I go to SiteTools -> Speed -> Caching -> Dynamic cache and flush the cache I see the following requests:

127.0.0.1 lmbo.org - [02/Apr/2023:18:04:53 +0000] "PURGE /* HTTP/1.1" 200 155 "-" "SiteGround Cache Flusher" | - | - - 0.000 - 0 NC:000000 UP:-DT
127.0.0.1 lmbo.org - [02/Apr/2023:18:04:53 +0000] "PURGE /* HTTP/1.1" 200 156 "-" "SiteGround Cache Flusher" | TLSv1.2 | - - 0.000 - 0 NC:000000 UP:-DT


These purge the cache successfully.

This is why the request I sent from localhost is:

$ curl -X PURGE http://127.0.0.1/* -H "Host: lmbo.org" --tlsv1.2
<html><head><title>Successful purge</title></head><body bgcolor="white"><center><h1>Successful purge</h1><p>Key : httplmbo.org/*</p></center></body></html>


This means sending the purge request from a localhost on http through tlsv1.2 and the result is a MISS:

$ curl -sILX GET lmbo.org/media/vendor/fontawesome-free/w.../fa-brands-400.woff2 | grep x-proxy-cache
x-proxy-cache: MISS


This means purging the cache works.

Once this resource accessed once, it is cache and consecutive requests resound with a HIT.

Presently there is no way for you to follow the immediate access log and see the requests which are being made, however, you are more than welcome to send a curl request the way that I did. If you get a HIT after flushing the cache, then the cache is not flushed properly.

Overall: The "Clean Cache" sends a request to flush the cache, however, the request is not effective. The request should be made on --tlsv1.2 in order to properly flush the dynamic cache.
Peter van Westen's Avatar Peter van Westen ADMIN
Please try the latest development version from:
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
On a side note. I did try it on a J3 site and it seems to work. That was PHP 7.4.
Peter van Westen's Avatar Peter van Westen ADMIN
Does the latest dev version work ok on J4? Or do you think the issue is down to the PHP version and Siteground itself?
Please post a rating at the Joomla! Extensions Directory
Dave Bishop's Avatar Dave Bishop
Hi Peter, I am still trying to figure it out. I think it is working. I installed it on a J4 site and saw a cache cleaning message showing 1.64 MB.

I will try it on the other site and have them look and get back to you. Thanks for the reminder.
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription