Jump to content

[Módulo gratis] Programar auto-borrado de caché de Prestashop cada X tiempo


Recommended Posts

Hay algunas tiendas que van conectadas a un ERP, o donde los productos se suben o se modifican a través de aplicaciones externos. En estos casos puede ocurrir que se hagan modificaciones en los productos y no se vean reflejadas inmediatamente en la portada de la tienda debido a la caché de Prestashop.

Parecido puede ocurrir con algunos módulos que muestran información de fuentes externas (por ejemplo, desde Facebook, Instagram o un blog externo), que a veces pueden actualizar la información y a pesar de eso que siga apareciendo en portada de la tienda la antigua, debido a que está cacheada.

Para todos esos casos se puede utilizar este módulo. Solo hay que instalarle, activarle e indicar cada cuánto tiempo se quiere que se borre la caché (por ejemplo, cada hora). Transcurrido ese periodo de tiempo, se efectuará automáticamente un borrado de la caché. También se puede elegir la activación mediante CRON, proporcionando una URL cuya llamada es posible programar en el CRON del servidor con el intervalo que se quiera para efectuar el borrado de la caché.

image.png.90d7468b8e4085bc1b6a49d4a570dd3b.png

Versión 2.1.0 disponible para Prestashop 1.6 y 1.7:

ftm_cacheclear.zip

Edited by Prestafan33 (see edit history)
  • Like 6
  • Thanks 5
Link to comment
Share on other sites

It's tested only with 1.7.x versions. Indeed, I think it can also work with 1.6 versions, because the only hook it's using was also at 1.6 versions, and it's also using "old" translation system, but I didn't tested it yet. If you want to try, the only you have to do is to open file ftm_cacheclear.php  before installation, and modify #30 line from:

$this->ps_versions_compliancy = array('min' => '1.7.0.0', 'max' => _PS_VERSION_);

to

$this->ps_versions_compliancy = array('min' => '1.6.0.0', 'max' => _PS_VERSION_);

Please, if you test it and it's working nicely let me know to make this change permanent.

Edited by Prestafan33 (see edit history)
Link to comment
Share on other sites

8 hours ago, speedcrash2013 said:

Hello. this module works with all versions of prestashop 1.6 and 1.7 ?

 

I tested it in v1.6 Prestashop installation and it's working right, so I changed versions compliance info and uploaded it again in first post of this thread.

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...
  • 1 year later...
On 7/5/2020 at 5:20 PM, Prestafan33 said:

 

Hello
I found your module and wanted to check if it works in the same way as my own small, raw module.
Since you use the same methods:
 

Tools::clearSmartyCache();
Tools::clearXMLCache();
Media::clearCache();
Tools::generateIndex();

I wonder it this solution really works.
After launching this by invoking proper url or through cron, the /var/cache/prod isn't flushed, and all files inside remain.
The only difference is index file that is being somehow refreshed or reindexed.
Is that supposed to be so? According to clear cache button in backoffice this isn't working the same, as it doesn't flush the var/cache/[prod] directory.
I'm wondering about adding a onliner bash script and invoke it through cron, or just  delete the directory using php.
But still I'm not sure how above mentioned methods work.

Edited by YoJoe (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...