MyBB Community Forums

Full Version: Deleting cache on themes effects forum?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi I just want to know I did a test and my speed result is not so good on forum and it shows by minifying /public_html/cache/themes/theme00 can save 45%

I want to delete it all in all since its cache does it effect the forum?

And also this is not the only one there is /cache/global.css also so if i delete who files in that cache folder will it be ok?
You can minify the files (and update the contents) without issues, but when they are regenerated (upon saving a CSS file) they will be overwritten. In my experience minifying css files doesn't really improve performance.

What you can try instead:
* Enable ZendOPCache, ApCache (you will need php.ini access, so a VPS or better) - will significantly reduce memory usage and load time
* Get a CDN for your static content (nothing like Cloudflare though...)
* Save /images/bg2.png as a JPG file, it will loose some quality but since this is a bagckground and only a small portion of it is actually visible you will save a lot of bandwith
* Send cache headers by placing the following .htaccess file in your /images directory
<IfModule mod_expires.c>
  ExpiresActive on

  ExpiresDefault "access plus 1 hour"

  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>
   
</IfModule>

As for CSS minification, set this up as a cronjob (run it every 30 minutes for example).

/minifycsscron.php
foreach (scandir('cache/themes/') as $themedir) {
  if (is_dir('cache/themes/'.$themedir) && $themedir != '.' && $themedir != '..') {
    foreach (scandir('cache/themes/'.$themedir) as $file) {
      if (is_file(scandir('cache/themes/'.$themedir.'/'.$file) && $file != '..' && $file != '..' && strpos($file, ".css") === strlen($file) - 4) {
        $css = file_get_contents('cache/themes/'.$themedir.'/'.$file);
        $css = str_replace(PHP_EOL, "", $css);
        file_put_contents('cache/themes/'.$themedir.'/'.$file, $content, $css);
      }
    }
  }
}
(2015-10-11, 11:50 AM)SentoWeb Wrote: [ -> ]You can minify the files (and update the contents) without issues, but when they are regenerated (upon saving a CSS file) they will be overwritten. In my experience minifying css files doesn't really improve performance.

What you can try instead:
* Enable ZendOPCache, ApCache (you will need php.ini access, so a VPS or better) - will significantly reduce memory usage and load time
* Get a CDN for your static content (nothing like Cloudflare though...)
* Save /images/bg2.png as a JPG file, it will loose some quality but since this is a bagckground and only a small portion of it is actually visible you will save a lot of bandwith
* Send cache headers by placing the following .htaccess file in your /images directory
<IfModule mod_expires.c>
  ExpiresActive on

  ExpiresDefault "access plus 1 hour"

  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>
   
</IfModule>

As for CSS minification, set this up as a cronjob (run it every 30 minutes for example).

/minifycsscron.php
foreach (scandir('cache/themes/') as $themedir) {
  if (is_dir('cache/themes/'.$themedir) && $themedir != '.' && $themedir != '..') {
    foreach (scandir('cache/themes/'.$themedir) as $file) {
      if (is_file(scandir('cache/themes/'.$themedir.'/'.$file) && $file != '..' && $file != '..' && strpos($file, ".css") === strlen($file) - 4) {
        $css = file_get_contents('cache/themes/'.$themedir.'/'.$file);
        $css = str_replace(PHP_EOL, "", $css);
        file_put_contents('cache/themes/'.$themedir.'/'.$file, $content, $css);
      }
    }
  }
}

Or, if you run MyBB 1.8, turn the setting on in ACP > Settings > Server & Optimisation Settings > Minify CSS. This way whenever the theme is updated via the ACP, a "X.min.css" file is generated and used Smile
(2015-10-11, 11:59 AM)Euan T Wrote: [ -> ]Or, if you run MyBB 1.8, turn the setting on in ACP > Settings > Server & Optimisation Settings > Minify CSS. This way whenever the theme is updated via the ACP, a "X.min.css" file is generated and used Smile

Hats off, I should reread the MyBB 1.8 release log. Time to get rid of some cronjobs I guess. Still, CSS minification gives little benefit compared to ZendOpCache and sending cache headers.
The code you provided above didn't help in getting speed improvement score....


and how can I set cronjob??? I really want to get from yslow D to B the minmum.
(2015-10-11, 12:03 PM)SentoWeb Wrote: [ -> ]
(2015-10-11, 11:59 AM)Euan T Wrote: [ -> ]Or, if you run MyBB 1.8, turn the setting on in ACP > Settings > Server & Optimisation Settings > Minify CSS. This way whenever the theme is updated via the ACP, a "X.min.css" file is generated and used Smile

Hats off, I should reread the MyBB 1.8 release log. Time to get rid of some cronjobs I guess. Still, CSS minification gives little benefit compared to ZendOpCache and sending cache headers.

Yeah, it's a small difference but I follow the rule of "every little helps". That, combined with offloading static files to a CDN or a subdomain without any cookies can really help shave off a little bit of time. Coupled with proper browser caching rules you can see a fairly noticeable speed increase.

The main cause is still PHP/MYSQL processing though which is why I normally use FastCGI caching in Nginx for guests to cache rendered pages for 15 minutes.
(2015-10-11, 12:04 PM)ytt Wrote: [ -> ]The code you provided above didn't help in getting speed improvement score....


and how can I set cronjob??? I really want to get from yslow D to B the minmum.

You might have missed Euan T's reply, in MyBB 1.8 this is a core feature so the cronjob isn't required. Sorry for the confusion.

Have you switched to a jpg format instead of png for bg2.png? If you follow those suggestions you will get an easily noticeable performance improvement.

(2015-10-11, 12:06 PM)Euan T Wrote: [ -> ]Yeah, it's a small difference but I follow the rule of "every little helps". That, combined with offloading static files to a CDN or a subdomain without any cookies can really help shave off a little bit of time. Coupled with proper browser caching rules you can see a fairly noticeable speed increase.

The main cause is still PHP/MYSQL processing though which is why I normally use FastCGI caching in Nginx for guests to cache rendered pages for 15 minutes.

I agree, there is nothing wrong with having this feature (that being said, it should be on by default - hint, hint).

You can afford to cache rendered pages for guests because you are aware of how your plugins work, but for everyone else this could break things, and even create security holes. For the average forum admin ZendOpCache, gzip compression and cache headers will give the biggest performance improvement.
(2015-10-11, 12:07 PM)SentoWeb Wrote: [ -> ]
(2015-10-11, 12:04 PM)ytt Wrote: [ -> ]The code you provided above didn't help in getting speed improvement score....


and how can I set cronjob??? I really want to get from yslow D to B the minmum.

You might have missed Euan T's reply, in MyBB 1.8 this is a core feature so the cronjob isn't required. Sorry for the confusion.

Have you switched to a jpg format instead of png for bg2.png? If you follow those suggestions you will get an easily noticeable performance improvement.

(2015-10-11, 12:06 PM)Euan T Wrote: [ -> ]Yeah, it's a small difference but I follow the rule of "every little helps". That, combined with offloading static files to a CDN or a subdomain without any cookies can really help shave off a little bit of time. Coupled with proper browser caching rules you can see a fairly noticeable speed increase.

The main cause is still PHP/MYSQL processing though which is why I normally use FastCGI caching in Nginx for guests to cache rendered pages for 15 minutes.

I agree, there is nothing wrong with having this feature (that being said, it should be on by default - hint, hint).

You can afford to cache rendered pages for guests because you are aware of how your plugins work, but for everyone else this could break things, and even create security holes. For the average forum admin ZendOpCache, gzip compression and cache headers will give the biggest performance improvement.

Yeah, exactly. At one point (several years ago now) I shared my .htaccess I sued to send cache headers, set correct mime types and enable gzip wherever possible. I'll have to try and dig it up again...
(2015-10-11, 12:07 PM)SentoWeb Wrote: [ -> ]
(2015-10-11, 12:04 PM)ytt Wrote: [ -> ]The code you provided above didn't help in getting speed improvement score....


and how can I set cronjob??? I really want to get from yslow D to B the minmum.

You might have missed Euan T's reply, in MyBB 1.8 this is a core feature so the cronjob isn't required. Sorry for the confusion.

Have you switched to a jpg format instead of png for bg2.png? If you follow those suggestions you will get an easily noticeable performance improvement.

(2015-10-11, 12:06 PM)Euan T Wrote: [ -> ]Yeah, it's a small difference but I follow the rule of "every little helps". That, combined with offloading static files to a CDN or a subdomain without any cookies can really help shave off a little bit of time. Coupled with proper browser caching rules you can see a fairly noticeable speed increase.

The main cause is still PHP/MYSQL processing though which is why I normally use FastCGI caching in Nginx for guests to cache rendered pages for 15 minutes.

I agree, there is nothing wrong with having this feature (that being said, it should be on by default - hint, hint).

You can afford to cache rendered pages for guests because you are aware of how your plugins work, but for everyone else this could break things, and even create security holes. For the average forum admin ZendOpCache, gzip compression and cache headers will give the biggest performance improvement.

Change image to jpg from png still 133kb size no difference.   I will try other methods to see if i can get better result my speed is good but i want to improve on the score on https://gtmetrix.com/reports/adminads.com/7zOQNUBD
(2015-10-11, 04:56 PM)ytt Wrote: [ -> ]
(2015-10-11, 12:07 PM)SentoWeb Wrote: [ -> ]
(2015-10-11, 12:04 PM)ytt Wrote: [ -> ]The code you provided above didn't help in getting speed improvement score....


and how can I set cronjob??? I really want to get from yslow D to B the minmum.

You might have missed Euan T's reply, in MyBB 1.8 this is a core feature so the cronjob isn't required. Sorry for the confusion.

Have you switched to a jpg format instead of png for bg2.png? If you follow those suggestions you will get an easily noticeable performance improvement.

(2015-10-11, 12:06 PM)Euan T Wrote: [ -> ]Yeah, it's a small difference but I follow the rule of "every little helps". That, combined with offloading static files to a CDN or a subdomain without any cookies can really help shave off a little bit of time. Coupled with proper browser caching rules you can see a fairly noticeable speed increase.

The main cause is still PHP/MYSQL processing though which is why I normally use FastCGI caching in Nginx for guests to cache rendered pages for 15 minutes.

I agree, there is nothing wrong with having this feature (that being said, it should be on by default - hint, hint).

You can afford to cache rendered pages for guests because you are aware of how your plugins work, but for everyone else this could break things, and even create security holes. For the average forum admin ZendOpCache, gzip compression and cache headers will give the biggest performance improvement.

Change image to jpg from png still 133kb size no difference.   I will try other methods to see if i can get better result my speed is good but i want to improve on the score on https://gtmetrix.com/reports/adminads.com/7zOQNUBD

Put the same .htaccess file in the /cache/ directory, that will add cache headers to the css files.

Compressed the file for you in case it helps.

Remember not to focus too much on these stats, you want to give your visitors the best experience. I would never sacrifice a single useful features because of load time and a ranking or two in Google (optimize yes, remove... no).
Pages: 1 2