Appearance
Optimization
After your website has been deployed into the production environment (a hosting or VPS), it's time to apply some optimization to make it work more stable and also improve performance.
Configuring the queues
There are some tasks that take some time to perform during a typical web request such as generating image conversions or sending the email notifications. Thankfully, Laravel allows you to easily create queued jobs that may be processed in the background. By moving time-intensive tasks to a queue, our application can respond to web requests with blazing speed and provide a better user experience to your customers.
By default, the queue system is configured with the sync
driver that uses the main thread for the execution of tasks which is useful only when you are in the development environment. When it's come to the production environment you should consider some other options to run your queue.
The easiest way to set up a queue connection is to use the database driver which requires less configuration. From your command line run the following commands:
INFO
You can skip this step if you follow our shared hosting installation method.
php artisan queue:table
php artisan migrate
And don't forget to instruct your application to use the database driver by updating the QUEUE_CONNECTION
variable in your application's .env
file:
QUEUE_CONNECTION=database
Finally, use queue:work
to start a queue worker and process new jobs as they are pushed onto the queue
php artisan queue:work
TIP
To keep the queue:work
process running permanently in the background, you should use a process monitor such as Supervisor to ensure that the queue worker does not stop running.
For more information about the Laravel queue system please read on Laravel Docs.
Setting up media optimization tools
Cartify use the Media Library package from Spatie to manage all the media, and it would be nice if you could install some of the following tools (optional of course) that will help optimize the media better. Those tools are:
Here's how to install all the optimizers on Ubuntu:
sudo apt install jpegoptim optipng pngquant gifsicle
npm install -g svgo
Here's how to install the binaries on macOS (using Homebrew):
brew install jpegoptim
brew install optipng
brew install pngquant
brew install svgo
brew install gifsicle