Too much bandwidth with database + cache problem

Popular automatic website translation tool

Too much bandwidth with database + cache problem

Postby machabeus » Mon Nov 15, 2010 9:25 pm

I have 2 problems with GTranslate. The first one is too much data tranfered with database generated by GTranslate (average is 20-30GB per day, at 500 visitors a day), and the second problem is with cache. It is generated milions of files, and do not delete it. So my small site is generating about 2-3 milions of files per week.
What more information are needed ?
machabeus
 
Posts: 1
Joined: Mon Nov 15, 2010 9:20 pm

Re: Too much bandwidth with database + cache problem

Postby Edvard » Tue Nov 16, 2010 1:13 pm

It doesn't transfer data through your database. It saves the cache files in the file system.

Probably you have many URLs and search engines are indexing your site translations, that's why it grows that fast.

You can put this code in your gtranslate/config.php to enable self clear function of the cached files.
Code: Select all
define('MAINLANG', 'en');

if(rand() % 20 == 0) {
    // purge expired cache
    $cached_files = array_diff(scandir('cache'), array('.', '..'));
    $now = strtotime('now');
    foreach($cached_files as $cached_file)
        if($now - filemtime('cache/'.$cached_file) > 1.5 * CACHETIME)
            unlink('cache/'.$cached_file);
}
...
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4183
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Too much bandwidth with database + cache problem

Postby pert7 » Thu Dec 16, 2010 11:55 pm

I have the same problem with the cache!

If I put this code in config.php, how often will be cleared the cache directory? May I get an error 302 with this configuration?
pert7
 
Posts: 13
Joined: Thu Dec 16, 2010 11:43 pm

Re: Too much bandwidth with database + cache problem

Postby pert7 » Fri Dec 17, 2010 9:54 pm

Can you support me please? I bought this product..
pert7
 
Posts: 13
Joined: Thu Dec 16, 2010 11:43 pm

Re: Too much bandwidth with database + cache problem

Postby Edvard » Mon Dec 20, 2010 5:14 pm

Hi, the cache folder will be cleared 1.5 times the cache time specified in config.php file. By default it is set to 20 days. If you don't decrease the cache time and you have an average website with 1000 visitors a day you will not get that error.
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4183
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Too much bandwidth with database + cache problem

Postby pert7 » Mon Dec 20, 2010 8:13 pm

I have 1000-2000 visitors per day and I hope do not have this problem. Is it right the position of the code? Thank you very much!

Code: Select all
<?php
define('LICENSE', 'license.dat');
define('CACHETIME', 82600); //20 days
define('MAINLANG', 'el'); // en, ar, bg, hr, cn, ct, cs, da, et, tl, fi, fr, gl, el, iw, hi, es, nl, id, ja, ca, ko, lt, lv, mt, de, no, pt, ru, ro, sr, sk, sl, sv, th, tr, uk, hu, vi, it, pl, sq

if (!function_exists('file_put_contents')) {
    function file_put_contents($filename, $data) {
        $f = @fopen($filename, 'w');
        if (!$f) {
            return false;
        } else {
            $bytes = fwrite($f, $data);
            fclose($f);
            return $bytes;
        }
    }
}

if (!function_exists('file_get_contents')) {
    // Define function and arguments
    function file_get_contents($file, $include=false) {
        // Varify arguments are correct types
        if (!is_string($file))  return(false);
        if (!is_bool($include)) return(false);

        // Open the file with givin options
        if (!$handle = @fopen($file, 'rb', $include)) return(false);
        // Read data from file
        $contents = fread($handle, filesize($file));
        // Close file
        fclose($handle);

        // Return contents of file
        return($contents);
    }
}

define('MAINLANG', 'el');

if(rand() % 20 == 0) {
    // purge expired cache
    $cached_files = array_diff(scandir('cache'), array('.', '..'));
    $now = strtotime('now');
    foreach($cached_files as $cached_file)
        if($now - filemtime('cache/'.$cached_file) > 1.5 * CACHETIME)
            unlink('cache/'.$cached_file);
}



Also, I receive this javascript error in IE:
Code: Select all
The 'window.jstiming.load' είναι μηδενικό ή δεν είναι αντικείμενο
line: 193
Character: 478
Code: 0
URI: http://translate.googleusercontent.com/translate/static/biEfM_qFbxU/js/translate_c.js
pert7
 
Posts: 13
Joined: Thu Dec 16, 2010 11:43 pm

Re: Too much bandwidth with database + cache problem

Postby pert7 » Thu Jan 06, 2011 2:17 am

Unfortunately, the error 302 message appeared again!! The code don't helps... :-(
pert7
 
Posts: 13
Joined: Thu Dec 16, 2010 11:43 pm


  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

2GLux
cron