apache кеширование js файлов - PullRequest
       2

apache кеширование js файлов

1 голос
/ 13 августа 2011

Я настроил Apache под Windows, чтобы включить кеш, как это

    LoadModule expires_module modules/mod_expires.so
    LoadModule headers_module modules/mod_headers.so
    LoadModule deflate_module modules/mod_deflate.so

ExpiresActive On



ExpiresDefault "access plus 3 days"

ExpiresByType image/x-icon "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"


<IfModule mod_headers.c>
# YEAR
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$">
  Header set Cache-Control "max-age=29030400"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
  Header set Cache-Control "max-age=604800"
</FilesMatch>
# 45 MIN
<FilesMatch "\.(html|htm|txt)$">
  Header set Cache-Control "max-age=2700"
</FilesMatch>
</IfModule>

Когда я пытаюсь открыть файл js непосредственно в браузере (для тестирования), обновляя снова и снова, то каждый раз, когда я получаю статус ответа 200 с помощью Firebug. Не отправляется статус "304 Not Modified". Есть ли у вас идеи, как я могу этого достичь. Ниже приводится вывод заголовков Firebug.

Response Header
Date        Sat, 13 Aug 2011 01:18:15 GMT
Server      Apache/2.2.19 (Win32) PHP/5.3.6
Last-Modified   Sat, 13 Aug 2011 01:18:15 GMT
Etag        W/"100000000171d-34f08-4aa5f022d9780"
Accept-Ranges   bytes
Content-Length  216840
Cache-Control   max-age=604800
Expires     Tue, 16 Aug 2011 01:18:15 GMT
Keep-Alive      timeout=5, max=100
Connection      Keep-Alive
Content-Type    application/javascript

Request Header

Accept          text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection          keep-alive
Cookie          PHPSESSID=5k947khv1j27itd7mtp5evtg07
If-Modified-Since   Sat, 13 Aug 2011 01:03:42 GMT
If-None-Match   W/"100000000171d-34f08-4aa5f022d9780"
Cache-Control   max-age=0

1 Ответ

1 голос
/ 13 августа 2011

Запрос содержит if-Modified-Since -header:

 Sat, 13 Aug 2011 01:03:42 GMT

Но в ответе содержится последний измененный -заголовок со временем, более поздним:

Sat, 13 Aug 2011 01:18:15 GMT

.. поэтому файл должен быть загружен снова.

Попробуйте сбросить последний измененный заголовок: http://www.askapache.com/htaccess/apache-speed-last-modified.html

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...