Notifications
Clear all

[Solved] Wpforo Cache / S3 Uploads

11 Posts
3 Users
0 Reactions
699 Views
sc89me
Posts: 28
Topic starter
(@sc89me)
Eminent Member
Joined: 5 years ago

Question regarding cache, I have had to disable this because when running S3 Uploads plugin by humanmade its trying to offload anything put into /uploads/ including the cache off to S3 this increases forum load times to over 100 seconds per page load when its enabled (I have disabled it) 

I would like to use the cache but can not find a method of overriding the location it stores the cache to keep this locally vs the plugin trying to offload it to S3 because of where its being stored. 

Is this possible or is cache simply not usable in this instance? 

10 Replies
Chris
Posts: 3627
(@chris)
Famed Member
Joined: 3 years ago

Hi @sc89me,

We understand the issue, but the problem is that we don't have any option to change the folder of the cache. 

Can you check, maybe, there is an option to exclude a folder? If no, please contact the creators with the issue. 

I'm sorry but we can't do anything from our side.

sc89me
Posts: 28
Topic starter
(@sc89me)
Eminent Member
Joined: 5 years ago

we don't have any option to change the folder of the cache.

I see you don't but are you saying as plugin authors you can't create such an option or you won't create such an option? 

Looking in the Cache class in the plugin it doesn't seem overly difficult to change this to another location but because its (all the filters) are wrapped up in the class and can't be accessed from another plugin / theme it seems impossible to modify this without modifying the core files in your plugin. 

I will check for the ability to exclude paths in S3 Uploads plugin but to my knowledge they don't have this but I will go investigate. 

EDIT: Just checked they state there is no method of excluding a path and you have to change the path on the thing trying to store files. So I guess this is an incompatibility with your plugin and S3 then as far as cache goes. 

1 Reply
Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3627

@sc89me,

How does the forum work with disabled cache?

sc89me
Posts: 28
Topic starter
(@sc89me)
Eminent Member
Joined: 5 years ago

Well when its on the load times can be over 100 seconds. When its over they are 4-5 seconds which is why would would like to get it working in order to see if it can speed this up. @Chris

1 Reply
Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3627

Yes, that really slow. I'm sorry to say this, but we don't have any option to do anything.

sc89me
Posts: 28
Topic starter
(@sc89me)
Eminent Member
Joined: 5 years ago

but we don't have any option to do anything.

I modified : wpforo\classes\Cache.php

Added: 

$cache_dir = apply_filters('wpforo_cache_dir', $folders['cache']['dir'], $folders);

To the construct: 

function __construct() {
add_action( 'wpforo_after_init_folders', function( $folders ) {
$cache_dir = apply_filters('wpforo_cache_dir', $folders['cache']['dir'], $folders);

This let me change the directory to another directory, it took the query count on forum load down from 1000+ to 500 queries and shaves 2-3 seconds off page load. 

Can this be in the next release? 

4 Replies
Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3627

@sc89me,

You can use this hook for it, but not that the function in it is an example, code that would crush the page but show the cache file path, so you need to manage it by your needs.

Please note. We don't know if this will work without problems.

add_action( 'wpforo_after_init_folders', function(){
    //var_dump(WPF()->folders);
    //die;
} );
sc89me
(@sc89me)
Joined: 5 years ago

Eminent Member
Posts: 28

I already tried using this before starting this thread. 

This is an "action" this doesn't work in the same way as filters do. 

It doesn't allow you to "change" anything only trigger an action to happen at that point.

Robert
Admin
(@robert)
Joined: 9 years ago

Support Team
Posts: 10591

Hi @sc89me,

It's done. This code will be available in the next version:

function __construct() {
	add_action( 'wpforo_after_init_folders', function( $folders ) {
	$cache_dir = apply_filters('wpforo_cache_dir', $folders['cache']['dir'], $folders);
			
sc89me
(@sc89me)
Joined: 5 years ago

Eminent Member
Posts: 28