ARCANEDEV / Localization

:globe_with_meridians: Localization package for Laravel
MIT License
185 stars 37 forks source link

Translated route slow #132

Closed quienti closed 5 years ago

quienti commented 5 years ago

Description:

Hi,

I'm facing issues with my translated routes I've several urls that are translated as below

Route::transGet(
    'routes.support.admin.ticket.index',
    'Ticket\IndexController@index'
)->name('admin.support.ticket')->middleware(['permission:support_ticket']);

It actually roughly take 3 seconds to load. If I remove all my translated routes, this same page loads way faster (300ms)

Thank you in advance for your help

arcanedev-maroc commented 5 years ago

Hi,

The only advice i can give you for now is caching the config files with php artisan config:cache.

Note: The middlewares + many routes + db queries can slows down your requests/responses but 3 seconds is not bad if your app isn't an e-commerce website for your clients (based on google articles).

For the time being, the translated routes are not cachable but i work on it (rewrite) when i got some spare time.

mkwsra commented 5 years ago

Indeed it's super slow, unfortunately, and I believe all of us should work on caching them, it's critical

cbaconnier commented 5 years ago

I used to have the same issue #103 a year ago and did a fork to make a workaround. The fork implies that you MUST use named routes.

I don't know if the fork would still be compatible with the actual version. I was just passing by wondering if a solution was found since then.

https://github.com/melba-ch/Localization/commit/d76d2502adb3f029b5f7072792739cd3b220bf7b