2015-04-04 62 views
3

GWT的完美缓存documntation(http://www.gwtproject.org/doc/latest/DevGuideCompilingAndDebugging.html#perfect_caching)建议将下列行添加到我的.htaccess文件:由于我没有使用.htaccess文件通过Apache 2.2 httpd.conf配置GWT缓存?

<Files *.nocache.*> 
    ExpiresActive on 
    ExpiresDefault "now" 
    Header merge Cache-Control "public, max-age=0, must-revalidate" 
</Files> 

<Files *.cache.*> 
    ExpiresActive on 
    ExpiresDefault "now plus 1 year" 
</Files> 

,但有机会获得Apache 2.2的httpd.conf文件我宁愿在那里添加那些行。

但是在哪里/如何?

感谢您的任何建议。

回答

3

<Files>指令的说明明确指出,你可以使用它:

上下文:服务器配置,虚拟主机,目录,.htaccess

在大多数情况下,你可能想要将它添加到您的应用程序的virtual host(如果您希望缓存规则仅适用于该应用程序)或服务器的配置(在任何指令之外(通常位于httpd.conf中)) - 如果您想要全局应用这些规则(如果您服务器上有多个GWT应用程序)。

如果你想在一个虚拟主机指令的使用方法:

<VirtualHost *:80> 
    ServerName host.example.com 

    #... 

    <Files *.nocache.*> 
     ExpiresActive on 
     ExpiresDefault "now" 
     Header merge Cache-Control "public, max-age=0, must-revalidate" 
    </Files> 

    <Files *.cache.*> 
     ExpiresActive on 
     ExpiresDefault "now plus 1 year" 
    </Files> 
</VirtualHost> 

如果你想在全球范围内使用它们,只是把它们在httpd.conf,任何指示之外。