gpt4 book ai didi

.htaccess - create-react-app 利用 HTTP 缓存

转载 作者:行者123 更新时间:2023-12-02 11:21:48 27 4
gpt4 key购买 nike

我最近用过 create-react-app制作和部署网站。我在 tools.pingdom.com 上运行了网站速度测试,它看起来基本不错。但是,我在利用浏览器缓存方面获得了 F。更具体地说,它说明了以下资源:

http://www.onlineomnichord.com/static/css/main.3d9308b8.css
http://www.onlineomnichord.com/static/js/main.7a110dad.js

保鲜期短。

我正在使用 heroku 来托管我的网站,所以我阅读了他们的一些建议。末this article on HTTP caching他们说缓存应该在 web 框架内实现。

有没有办法在我的 react 项目中的某处指定缓存 header ?我还阅读了 create-react-app user guide ,他们说你可以使用 .htaccess Apache HTTP 服务器的文件。有没有类似于我应该利用的东西?

最佳答案

https://stackoverflow.com/a/51880901/7023191

React use SWPrecache to cache all files that webpack builds. So if you want your css to be cached, you need to include it in your react app (and not in the index.html). add inside app.jsx :

import 'bootstrap-override.css';

关于.htaccess - create-react-app 利用 HTTP 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45005595/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com