使用.htaccess

时间:2016-07-28 12:09:29

标签: http caching http-headers

这是我的http.confg文件:

Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>
<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
Include /etc/phpmyadmin/apache.conf

这是我的.htaccess文件:

<FilesMatch "\.(xml)$">
Header unset ETag
FileETag None
Header set Cache-Control "max-age= 300, public"
</FilesMatch>

这是我试验的链接:` http://ec2-54-226-158-192.compute-1.amazonaws.com/LiveTV.xml

(1)当我第一次在Mozilla Firefox上指向此链接时,

这是我在服务器端听的内容: enter image description here

这就是我在客户端使用wire-shark收集的内容。enter image description here

(2)现在我再次发送请求:

这是我在服务器端收听的内容:enter image description here

这就是我在客户端使用wire-shark收集的内容。enter image description here

(3)当max-age到期时,我再次发送请求:

这是我在服务器端听的内容: enter image description here

这是我在客户端使用wire-shark收集的内容。 enter image description here

我的问题是:

  • 为什么我在服务器端获得Cache-Control: max-age=0

  • 我不能在max-age到期后收到200回复​​吗?为什么我在max-age到期后的第一个请求中获得304状态代码?

0 个答案:

没有答案