2017-02-04 1 views
1

최근에 웹 응용 프로그램로드 속도 (Laravel 5.1을 사용하여 빌드 됨)를 확인하고있었습니다. 그리고 나는 Leverage browser caching을 발견했다. 그래서 나는 이것에 대한 해결책을 찾기 위해 그것을 봤지만 작동하지 않는 것 같습니다.Laravel 5.1 응용 프로그램 용 브라우저 캐싱 활용

는 그것은 다음과 같은 코드를 추가 언급되었다 : htaccess로의

<IfModule mod_expires.c> 
    ExpiresActive on 

# Perhaps better to whitelist expires rules? Perhaps. 
    ExpiresDefault "access plus 1 month" 

# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) 
    ExpiresByType text/cache-manifest "access plus 0 seconds" 

# Your document html 
    ExpiresByType text/html "access plus 0 seconds" 

# Data 
    ExpiresByType text/xml "access plus 0 seconds" 
    ExpiresByType application/xml "access plus 0 seconds" 
    ExpiresByType application/json "access plus 0 seconds" 

# Feed 
    ExpiresByType application/rss+xml "access plus 1 hour" 
    ExpiresByType application/atom+xml "access plus 1 hour" 

# Favicon (cannot be renamed) 
    ExpiresByType image/x-icon "access plus 1 week" 

# Media: images, video, audio 
    ExpiresByType image/gif "access plus 1 month" 
    ExpiresByType image/png "access plus 1 month" 
    ExpiresByType image/jpg "access plus 1 month" 
    ExpiresByType image/jpeg "access plus 1 month" 
    ExpiresByType video/ogg "access plus 1 month" 
    ExpiresByType audio/ogg "access plus 1 month" 
    ExpiresByType video/mp4 "access plus 1 month" 
    ExpiresByType video/webm "access plus 1 month" 

# HTC files (css3pie) 
    ExpiresByType text/x-component "access plus 1 month" 

# Webfonts 
    ExpiresByType application/x-font-ttf "access plus 1 month" 
    ExpiresByType font/opentype "access plus 1 month" 
    ExpiresByType application/x-font-woff "access plus 1 month" 
    ExpiresByType image/svg+xml "access plus 1 month" 
    ExpiresByType application/vnd.ms-fontobject "access plus 1 month" 

# CSS and JavaScript 
    ExpiresByType text/css "access plus 1 year" 
    ExpiresByType application/javascript "access plus 1 year" 

    <IfModule mod_headers.c> 
    Header append Cache-Control "public" 
    </IfModule> 

</IfModule> 

을 공개 디렉토리 내에. 그러나 나는 여전히 Leverage browser caching에 대한 추천을 얻는다. 이걸 도와주세요. 나는 이것에 대한 해결책을 찾을 수 없다. 내가 페이지 로딩 속도를 확인

사이트는 다음과 같습니다

  1. Google 페이지 속도
  2. gtmetrix.com

당신에게

답변

0

은 '아무튼 그 이유 감사 이전에 <IfModule>을 종료하는 것을 잊어 버렸기 때문에 새로운 것을 열어.

그것은 이렇게 될 필요가있다 :

<IfModule mod_headers.c> 
Header append Cache-Control "public" 
</IfModule> 

## EXPIRES CACHING ## 
<IfModule mod_expires.c> 
ExpiresActive On 
ExpiresByType image/jpg "access plus 1 year" 
ExpiresByType image/jpeg "access plus 1 year" 
ExpiresByType image/gif "access plus 1 year" 
ExpiresByType image/png "access plus 1 year" 
ExpiresByType text/css "access plus 1 month" 
ExpiresByType application/pdf "access plus 1 month" 
ExpiresByType text/x-javascript "access plus 1 month" 
ExpiresByType application/x-shockwave-flash "access plus 1 month" 
ExpiresByType application/x-javascript "access plus 1 month" 
ExpiresByType text/javascript "access plus 1 month" 
ExpiresByType application/javascript "access plus 1 month" 
ExpiresByType application/json "access plus 1 month" 
ExpiresByType image/x-icon "access plus 1 year" 
ExpiresDefault "access plus 2 days" 
</IfModule> 
## EXPIRES CACHING ## 

나는 당신이 그것을에 필요한 모든 것을 포함해야 추가 한 레버리지 브라우저 캐싱. js?=ver 파일을 포함합니다.

+0

답장을 보내 주셔서 감사합니다. 그러나 문제는 여전히 동일합니다. font-awesome.min.css, bootstrap.min.css, jquery.min.js 등과 같은 모든 CSS 및 JS 파일에 대한 권장 사항이 제공됩니다. –

+0

캐싱이 전혀 작동하지 않습니까? 아니면 그냥 그 중 일부입니까? – Lag

+0

그것의 전혀 작동하지 않는다 –

관련 문제