All add-ons currently require PHP 7.4 or greater.

On July 4th 2024 PHP 8.2 will be the new minimum requirement for all add-ons. Expect any add-on released after that date to require 8.2 or greater. Some releases may not immediately take advantage of 8.x specific features in PHP, which means you might, be able to continue using new releases in PHP 7.4, however, if you experience an error the first thing you should do is update to PHP 8.2 then create a support ticket if the error persists.

Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Configure Redis using Unix sockets?

Status Resolved
Add-on / Version Speedy 1.8.1
Severity
EE Version 7.2.15 Pro

University Communications

Nov 01, 2023

Hi,
My server admin has enabled Redis but says that it’s set up to use Unix sockets instead of ports. Can Speedy be configured to use Redis this way, and what would be the config settings I’d need to use:

$config['speedy_redis_settings'] = [
    'static' => 'yes',
    'servers' => [
        [
            'host' => '127.0.0.1',
            'port' => '6379',
            'timeout' => '0',
            'password' => null,
        ]
    ],

Thanks!

 

#1

BoldMinded (Brian)

I’m not sure what the socket connection looks like, but based on the docs you pass the socket info through as the host parameter, and the port is optional.

#2

University Communications

Thanks, that seemed to work. However, now when I try to enable static caching, the “Regenerate files” link doesn’t work. Clicking it doesn’t clear the “Regenerate files” prompt, it just persists ( see screenshot here: https://today.ucsd.edu/news_uploads/redis-static.png ). Also, the index_redis_default_site.php file isn’t generated. It does seem to be caching pages to Redis in the static folder.

Here’s what I have in config.php:

$config['speedy_enabled'] = 'yes';
$config['speedy_static_enabled'] = 'yes';
$config['speedy_break_async'] = 'no';
$config['speedy_driver'] = 'redis';
$config['speedy_redis_settings'] = [
    'static' => 'yes',
    'servers' => [
        [
            'host' => '/home/ucsdstage/.redis/redis.sock',
            'timeout' => '0',
            'password' => null,
        ]
    ],
];
$config['speedy_ttl'] = 3600;

Thanks

#3

BoldMinded (Brian)

That sounds like the folders may not have write permissions?

#4

University Communications

I did notice it was trying to write to the private_html directory for some reason. It should be public_html. (private_html is a symlink to public_html)

#5

University Communications

I was able to get the utility files to regenerate and it is caching pages to Redis. But it’s still not generating the index_redis_default_site.php so the redirects to the cached content isn’t working. How can I get the index_redis_default_site.php generated? And I assume it’s supposed to be located in the web root? Thanks

#6

BoldMinded (Brian)

Comment has been marked private.

#7

University Communications

Sorry, that didn’t work. I also tried deleting all Speedy tables from the db, deleting the static folder and reinstalling Speedy, but no luck. It also won’t generate the utilities folder now. Any other ideas?

Thanks

#8

BoldMinded (Brian)

Is the site name “default_site”, or something else?

#9

University Communications

Yes, in the static folder, the generated folder is called default_site.

#10

BoldMinded (Brian)

Have you checked the server logs for anything? I did a test locally and it creates everything as expected, and I haven’t had similar reports from other users, which usually indicates it’s an environment specific issue.

#11

University Communications

Hi, I checked server logs but didn’t see anything unusual. Is it possible for you to just send me the necessary utility files so I can at least get it working? Thanks

#12

BoldMinded (Brian)

What is it generating? Can you share screenshots of your directories? I can’t just send the file because it is not going to be the same for every site. It generates the file with pre-defined variables and such.

Have you tried installing EE and Speedy on a different server to see if you get the same result?

#13

BoldMinded (Brian)

and you’re 100% positive the public folder where your index.php file is currently located is writable? Have you tried chmod 777 on that directory?

#14

University Communications

Yes, public_html was set to 755 and writable. Even after I set it to 777 it’s still exhibiting the same behavior.

So I’ve tried this on two different servers - stage and production - and it does the same thing on both. When using file caching, it is able to generate the correct utility files and static caching works fine. See screenshots: https://today.ucsd.edu/news_uploads/path_public_html.png https://today.ucsd.edu/news_uploads/path-public_html-static.png https://today.ucsd.edu/news_uploads/path-public_html-static-utilities.png

When I switch to Redis as the driver, it gives the prompt to regenerate files but then does nothing when I click on the regenerate link. Again, I’m configuring using sockets so not sure if this difference is causing the issue.

Not sure if this makes a difference, but we also recently migrated to new servers (and also moved the old database). On the old server, we were using Speedy with static file caching (not Redis).

Thanks

#15

BoldMinded (Brian)

Did you try to manually delete those files prior to switching from File to Redis? E.g. start from a clean slate?

#16

BoldMinded (Brian)

Comment has been marked private.

#17

University Communications

Well, a couple of interesting things happened:

  • It still wasn’t working, but then I opened my Chrome developer tools to check the network processes. When I did that, the regenerate link did work. I have it set to clear my browser cache when developer tools is open so maybe it was a cookie or browser cache issue?
  • It did generate the index_redis_default_site.php file but it wasn’t where I was looking. It put it in the system folder (which is called maserati in the developer logs screenshot). Isn’t it supposed to be in the document root?

Here’s the developer logs: https://today.ucsd.edu/news_uploads/devlog.png

#18

University Communications

Redis with partial caching is working but it’s not redirecting to fully static cached pages

#19

BoldMinded (Brian)

What is the “maserati” folder? When Speedy writes the file it’s using EE’s constant FCPATH, which should always be the value of where the front controller is, in this case, index.php. Is that constant being modified in any way on your project?

#20

University Communications

“maserati” is the name of the EE system folder. I’m not sure why FCPATH would have been modified. I do see index.php in the web root as well as in maserati. The one in the root directory defines the system path:

$system_path = './maserati';

The one in maserati doesn’t contain the system path.

#21

BoldMinded (Brian)

So with the index file moved to the correct location is everything working?

#22

University Communications

Yes static caching is working now, I just had to change this line in the index_redis file to point to the index.php in the web root:

// No cached response, proceed with normal EE operations.
require_once '/home/ucsdstage/domains/stage-today.ucsd.edu/public_html/index.php';
exit;

Oddly the browser seems to be caching the static cache files, which is not good if the Speedy cache needs to be broken. I assume this probably has to do with some caching directive in my htaccess file and nothing to do with Speedy? Thanks

#23

BoldMinded (Brian)

Yes, that sounds like an htaccess re-write issue, which I don’t offer support on. Start with the bare minimum htaccess file from my docs and see if it works with that. I’ve seen sites with huge crazy htaccess files, so make a back up of yours and start fresh, then work from there.

#24

University Communications

Yes, I found the htaccess directive that was caching html so now everything seems to be working as expected. I just had a couple more thoughts below and then I think we can close this ticket:

  • Did you have any thoughts on how to modify the FCPATH variable? I’m not sure why there’s another index.php file in the system folder, but maybe just delete that?
  • Not sure if you’re aware, but your email notifications for support updates doesn’t seem to be working.

Thanks!

#25

University Communications

Actually, I was just testing the cache clearing rules using Redis and can’t seem to clear the homepage. What would be rule for that? Speedy shows that it’s being cached under ‘static’ but the item isn’t selectable (it’s just blank). I also tried clearing it with a tag but that didn’t seem to work either. Thanks

#26

BoldMinded (Brian)

I don’t know what “but the item isn’t selectable (it’s just blank)” means, can you share a screenshot or video?

#27

BoldMinded (Brian)

I have no idea what’s going on with your FCPATH constant, but to be sure there wasn’t a bug with Speedy writing out the index file correctly I moved my system folder above the web root in my test environment, similar to what you have, and it generated the files just fine. Do you have some custom config file thing going on? Like Focus Lab multi-environment config file?

https://www.dropbox.com/scl/fi/7klwbuymppebpa41fuab6/Screenshot-2023-11-14-at-4.47.54-AM.png?dl=0

#28

University Communications

Hi, here’s a video showing the homepage being cached: https://today.ucsd.edu/news_uploads/static-homepage.mov

When I go to look at the homepage item in Speedy, it is cached but doesn’t show up because the URL for the homepage doesn’t have a path. So the key for the item is apparently blank?

In the past when I’ve used disk caching, the homepage key will show up as just “static,” but now with Redis nothing shows up.

#29

BoldMinded (Brian)

Comment has been marked private.

#30

University Communications

Hi, I tried using that build but it’s still doing the same thing - homepage is cached but the item doesn’t show up.

Also, it looks like I can’t access the dropbox link of the screenshot in comment #27: https://www.dropbox.com/scl/fi/7klwbuymppebpa41fuab6/Screenshot-2023-11-14-at-4.47.54-AM.png?dl=0

Thanks

#31

BoldMinded (Brian)

The shared image should work now.

I was able to replicate the same issue you had where the home page was not creating a named Redis key when static caching was enabled. I made a change so it would create a key called “home”, tested to confirmed it worked, and then created the build I sent you. You’re saying after clearing your cache, and reloading the home page, that the same behavior persists and it does not create a Redis key named “home”?

#32

University Communications

Hi, yes, the same behavior persists and it doesn’t create a key named “home.” Here’s a video showing that the code was updated to the latest build you sent me, then when I cache the homepage, the key “home” isn’t showing up in Speedy: https://today.ucsd.edu/news_uploads/static-homepage-2.mov

I also tried using the url_override parameter which did rename the key, but it also caused the caching redirect to stop working. Thanks

#33

BoldMinded (Brian)

What does your {exp:speedy:static} tag look like? Have you tried {exp:speedy:static url_override=”home”} in the home page template?

#34

BoldMinded (Brian)

Sorry I didn’t read the last line of your comment.

#35

BoldMinded (Brian)

What do you have on line 504 of the mod.speedy.php file?

#36

University Communications

I showed that line 504 in the video. It’s this:

$uriString = ee()->uri->uri_string() ?: 'home'; // If there is no URI, assume it's the home page.
#37

BoldMinded (Brian)

and this is working for every page but the home page? You see all the cache keys etc?

#38

University Communications

Yes, it’s working for every page but the homepage. I can see the cache keys for all other pages and clear them with the cache-clearing rules. That’s all I really want to be able to do with the homepage. Do you know why clearing it using the tag parameter wouldn’t work?

#39

BoldMinded (Brian)

Have you taken a look at the exp_speedy_tags table to see if the tag you’re using exists? If so share a screenshot of it.

#40

University Communications

Here is the tag in exp_speedy_tags: https://today.ucsd.edu/news_uploads/speedy-tags.png The double trailing slashes in the key doesn’t look right?

#41

BoldMinded (Brian)

Comment has been marked private.

#42

University Communications

Hi, I tried that build and it still inserted a double slash at the end. I did confirm this new code was at line 555 of mod.speedy.php. But where is it calling reduce_double_slashes from? I don’t see that function anywhere:

return ee()->security->sanitize_filename(
            $this->utf8Decode(
                reduce_double_slashes(
                    trim($url, '/')
                )
            ), true);

I also did confirm that clearing the cache using the tag parameter does work when I manually remove the trailing slash from the database.

#43

BoldMinded (Brian)

So what does your {exp:speedy:static} tag look like? Can you share the template code for the home page?

#44

University Communications

{exp:speedy:static tags="home"}
#45

BoldMinded (Brian)

Are you able to provide CP and FTP access so I can login and debug this? If so edit the ticket end use the provided fields for the credentials.

#46

University Communications

Hi yes, I can provide that but the staging site is only accessible on a VPN from certain IP blocks. I could probably get the server admin to add your IP.

#47

BoldMinded (Brian)

What does your htaccess file look like? Are you intentionally adding a trialing slash to the re-writes?

#48

University Communications

I’m not sure if this would add a trailing slash? I can send the whole htaccess file if you want

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /

 # Removes index.php from ExpressionEngine URLs
 RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
 RewriteCond %{REQUEST_URI} !/maserati/.* [NC]
 RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

 # Directs all EE web requests through the site index file
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
#49

BoldMinded (Brian)

That file looks fine. Is there anything else out of the ordinary with this project? Is it hosted on a Windows machine or something like that?

Have you tried setting up a fresh EE install with just Speedy installed, a single home page template, and tried to replicate this?

#50

University Communications

Hi, I edited the ticket with cp and ftp info. I temporarily opened ports so you should be able to access the site. This is not hosted on a Windows machine. It’s Alma Linux. I have not tried a fresh EE install to replicate the issue yet.

Thanks!

#51

BoldMinded (Brian)

It has something to do with the Freebie add-on. This is why I was asking for a clean EE install to be created with just Speedy to replicate the issue… another add-on is causing the issue. Try disabling Freebie.

#52

BoldMinded (Brian)

Comment has been marked private.

#53

University Communications

Thanks! This build did work once I disabled Freebie. Will I have to disable Freebie going forward then? I was planning to remove Freebie from our code anyway as it is an obsolete add-on.

#54

BoldMinded (Brian)

Yeah I would recommend not using Freebie if you can and keep it disabled.

#55

University Communications

I did test the cache clearing rules using static/index and that didn’t work. I also tried static/index/. I also tried clearing it using tags but that still isn’t working even though the trailing double slash is gone. Thanks

#56

University Communications

Actually I just tested this on staging and cache clearing using static/index does seem to be working now. (I was testing this on my local machine before.)

#57

BoldMinded (Brian)

So everything is working now?

#58

University Communications

Yes, everything seems to be working now after testing. I just need to figure out the FCPATH issue but can work around that for now. Thank you for your help!

Login to reply