优化 Laravel 网站打开速度

1.关闭debug
打开.env文件,把debug设置为false.
APP_ENV=local
APP_DEBUG=false
APP_KEY=xxxxxxxxx

2.缓存路由和配置
php artisan route:cache
php artisan config:cache

3.Laravel优化命令
php artisan optimize

4.composer优化
sudo composer dump-autoload optimize

5.使用Laravel缓存
使用Laravel的Cache方法缓存内容,有文件缓存,数据库缓存,redis缓存,使用redis也可以用predis组件,也可以多种缓存方式结合。在Laravel中使用缓存就是这么优雅方便:
$lists = Cache::remember('travel.destination.lists', 20, function () {
    return $this-destination-getList();
});

6.使用CDN
本站用的是七牛CDN,每月送你20G流量和20G存储空间,具体多少不记得了,总之对于小站来说完全足够了。

7.使用PHP 7并开启OPcache

8.nginx开启gzip压缩


Laravel 5 性能优化技巧

性能一直是 Laravel 框架为人诟病的一个点,所以调优 Laravel 程序算是一个必学的技能。

接下来分享一些开发的最佳实践,还有调优技巧,大家有别的建议也欢迎留言讨论。

这里是简单的列表:

生成配置信息缓存
php artisan config:cache

生成路由缓存
php artisan route:cache

生成类映射加载优化
php artisan optimize --force

自动加载优化
php composer dumpautoload

使用 Memcached 来存储会话 config/session.php
使用专业缓存驱动器 config/cache.php
数据库请求优化
为数据集书写缓存逻辑
使用即时编译器(JIT),如:HHVM、OpCache
前端资源合并 Elixir
1. 配置信息缓存
使用以下 Artisan 自带命令,把 

查看 OpenCV 当前的指令集优化状态


#include "stdafx.h"

#include 
#include 

using namespace std;
using namespace cv;

int main()
{
    //设置是否启用指令集优化特性
    //cv::setUseOptimized(true);
    //获取当前机器的CPU指令集支持特性
    bool opt_status = cv::useOptimized();
    cout < < "当前的指令集优化状态:" << opt_status << endl;
    //获取编译时配置
    cout << getBuildInformation() << endl;
    //检查硬件支持
    cout << "HardwareSupport:" << endl;
    cout << "CV_CPU_MMX: "    << checkHardwareSupport(CV_CPU_MMX) << endl;
    cout << "CV_CPU_SSE: "    << checkHardwareSupport(CV_CPU_SSE) << endl;
    cout << "CV_CPU_SSE2: "   << checkHardwareSupport(CV_CPU_SSE2) << endl;
    cout << "CV_CPU_SSE3: "   << checkHardwareSupport(CV_CPU_SSE3) << endl;
    cout << "CV_CPU_SSSE3: "  << checkHardwareSupport(CV_CPU_SSSE3) << endl;
    cout << "CV_CPU_SSE4_1: " << checkHardwareSupport(CV_CPU_SSE4_1) << endl;
    cout << "CV_CPU_SSE4_2: " << checkHardwareSupport(CV_CPU_SSE4_2) << endl;
    cout << "CV_CPU_POPCNT: " << checkHardwareSupport(CV_CPU_POPCNT) << endl;
    cout << "CV_CPU_FP16: "   << checkHardwareSupport(CV_CPU_FP16) << endl;
    cout << "CV_CPU_AVX: "    << checkHardwareSupport(CV_CPU_AVX) << endl;
    cout << "CV_CPU_AVX2: "   << checkHardwareSupport(CV_CPU_AVX2) << endl;
    cout << "CV_CPU_FMA3: "   << checkHardwareSupport(CV_CPU_FMA3) << endl;
    cout << "CV_CPU_AVX_512F: "   << checkHardwareSupport(CV_CPU_AVX_512F) << endl;
    cout << "CV_CPU_AVX_512BW: "  << checkHardwareSupport(CV_CPU_AVX_512BW) << endl;
    cout << "CV_CPU_AVX_512CD: "  << checkHardwareSupport(CV_CPU_AVX_512CD) << endl;
    cout << "CV_CPU_AVX_512DQ: "  << checkHardwareSupport(CV_CPU_AVX_512DQ) << endl;
    cout << "CV_CPU_AVX_512ER: "  << checkHardwareSupport(CV_CPU_AVX_512ER) << endl;
    cout << "CV_CPU_AVX_512IFMA512: "    << checkHardwareSupport(CV_CPU_AVX_512IFMA512) << endl;
    cout << "CV_CPU_AVX_512IFMA: " << checkHardwareSupport(CV_CPU_AVX_512IFMA) << endl;
    cout << "CV_CPU_AVX_512PF: "   << checkHardwareSupport(CV_CPU_AVX_512PF) << endl;
    cout << "CV_CPU_AVX_512VBMI: " << checkHardwareSupport(CV_CPU_AVX_512VBMI) << endl;
    cout << "CV_CPU_AVX_512VL: "   << checkHardwareSupport(CV_CPU_AVX_512VL) << endl;
    cout << "CV_CPU_NEON: "   << checkHardwareSupport(CV_CPU_NEON) << endl;
    cout << "CV_CPU_VSX: "    << checkHardwareSupport(CV_CPU_VSX) << endl;
    cout << "CV_CPU_AVX512_SKX: "  << checkHardwareSupport(CV_CPU_AVX512_SKX) << endl;
    cout << "CV_HARDWARE_MAX_FEATURE: " << checkHardwareSupport(CV_HARDWARE_MAX_FEATURE) << endl;
    return getchar();
}

Add Library: opencv_core.lib

Keyboard Hook

.h
class CFullWindowDlg : public CDialogEx
{
...
void SetHook();
}


.cpp
///全局变量
HWND g_hWnd = NULL;             //窗口句柄
HHOOK g_hlowKeyHook = NULL;     //低级键盘钩子句柄
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
///


//安装钩子  
void CFullWindowDlg::SetHook()  //为了操作窗体,我们将主窗体的句柄传进去  
{
	g_hWnd = this-