我试图在Apache服务器中部署由Gatsby生成的站点。按照盖茨比博士,缓存控件应该设置为public/page-data
缓存控制头应该是缓存控制: public,max-age=0,必须重新验证1。
因此,我在.htaccess文件夹中添加了一个public/page-data文件。由于某些原因,文件仍然被缓存,并且与http代码409冲突导致错误。
这是.htaccess文件的内容。
<FilesMatch "\.(html|htm|js|css|php|json)>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</FilesMatch>我做错什么了吗?有什么办法使/public/page-data的缓存失效吗?
更新
我得到409的那一页是
import React from 'react';
import PageContent from '../components/UI/PageContents';
import Layout from '../components/layout';
import SEO from '../components/seo';
const Contact = () => (
<Layout innerPage="nk-contact" headerText="Contact us">
<SEO title="Contact us" />
<PageContent>
<div className="row">
<div className="col-md-6">
<section className="mb-2">
<h2 data-aos="fade-right">Contact us at</h2>
{[
'+91 1111111',
'+91 2222222',
'+91 2222222',
'+91 2222222',
].map((number, index) => (
<span key={`call-${index}`}>
<a href={`tel:${number}`}>{number}</a>
<br />
</span>
))}
<div className="py-1 mb-4">
<h3 className="pt-3 pb-1 d-block">Email</h3>
</div>
</section>
</div>
<div className="col-md-6">
<section className="mb-1">
<h3 data-aos="fade-right">Our Timing</h3>
<p>Office timings: 9.00 am - 6.00 pm.</p>
</section>
</div>
</div>
<hr />
<h3 data-aos="fade-left" className="mb-3">
Our Sales address
</h3>
<div className="row">
<div className="col-md-6">
<address>
<strong> xxxxx</strong>
<br />
xxxxx
</address>
</div>
</div>
</PageContent>
</Layout>
);
export default Contact;发布于 2021-03-22 05:59:32
公用文件夹在每次代码编译(gatsby build)中都会被重做,因此很可能在每个代码部署中都会删除您的.htaccess。
说过,你至少有两种方法:
gatsby-plugin-htaccess这样的插件.htaccess中创建静态文件夹。放置在项目根目录中的静态文件夹正以相同的内部结构(无需盖茨比的处理或由其转换器进行处理)转移到/public,因此,如果您所在的位置是一个/static/.htaccess (如果您愿意的话),编译后将出现在公用文件夹中。https://stackoverflow.com/questions/66732189
复制相似问题