我一直在为 freecodecamp 做随机报价机项目,我似乎无法停止缓存 api 的响应。
我尝试过各种答案:
我以为我曾经有过这样的经历:
fetch(this.url, {cache: 'no-cache'})
.then(res => res.json())
Run Code Online (Sandbox Code Playgroud)
...但我只是在开发人员工具中禁用缓存。
请帮忙。:-D。
这是我一直试图让它发挥作用的地方: https ://codepen.io/JonathanDWood/pen/gRNNKx
我正在我的应用程序中加载一些缩略图图像,这些缩略图存储在谷歌云上,我已将缩略图对象公开并设置cache-control: public, max-age:2628000,这似乎在 chrome 上工作,我看到图像正在从缓存加载,但在 mozilla firefox 上这是不起作用,每当我重新加载页面时,我总是看到图像是从服务器请求的。我还检查了我没有disable cache签入开发人员工具,这是一个屏幕截图
每次我看到字节传输并且图像没有从缓存加载。
对此的任何帮助将不胜感激。谢谢。
在 5.2.9 spring 项目中
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>
Run Code Online (Sandbox Code Playgroud)
在 webmvc-config.xml 中。静态图像与标题一起提供cache-control: /*omissions */ no-cache。我正在尝试覆盖特定文件或文件夹的此标头。
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**">
<mvc:cache-control max-age="3600" cache-public="true"/>
</mvc:resources>
Run Code Online (Sandbox Code Playgroud)
如果我替换为上面的内容,它会按我想要的方式工作,但它针对所有文件。我尝试更具体一些,例如:
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/myImages/**">
<mvc:cache-control max-age="3600" cache-public="true"/>
</mvc:resources>
Run Code Online (Sandbox Code Playgroud)
但我不认为它喜欢有两个资源标签?我在文档中没有看到明确的方法来执行我想要的操作,但我对该领域不太熟悉。我不认为我想要一个“拦截器”?
我尝试在Azure API管理中设置缓存策略,如下所示:
<policies>
<inbound>
<base />
<cache-lookup vary-by-developer="false" vary-by-developer-groups="false" must-revalidate="true" downstream-caching-type="none" caching-type="internal">
<vary-by-query-parameter>KontoNr</vary-by-query-parameter>
</cache-lookup>
<set-backend-service id="apim-generated-policy" backend-id="LogicApp_GeldEinzahlen_APIM_f597e3433e7847cb9d689c3f95bf1d6d" />
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized. Access token is missing or invalid.">
<openid-config url="https://login.microsoftonline.com/1b7c4ba5-7701-49e7-94d8-5ddbc87f8b6e/v2.0/.well-known/openid-configuration" />
<required-claims>
<claim name="aud">
<value>7068cdb6-0e5c-49c5-aaa8-ec8fc941de22</value>
</claim>
</required-claims>
</validate-jwt>
<set-variable name="isKontoNr" value="@(context.Request.MatchedParameters["kontoNr"].ToString().Length != 10)" />
<choose>
<when condition="@(context.Variables.GetValueOrDefault<bool>("isKontoNr"))">
<return-response>
<set-status code="400" reason="Bad Request" />
<set-header name="WWW-Request" exists-action="override">
<value>Generell error="kontoNr invalid"</value>
</set-header>
</return-response>
</when>
</choose>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<cache-store duration="1000" />
</outbound>
<on-error>
<base />
</on-error>
</policies> …Run Code Online (Sandbox Code Playgroud) cache-control azure policies azure-api-management ibm-api-management
我有这个页面,让我们来称呼它 index.php
index.php有一个用户列表和一个删除用户按钮.这将带他们去removeUser.php
最后一行removeUser.php是回归index.php
但在Firefox中,它看起来仍然相同,普通用户不会在每次手动加载页面时知道如何进行硬刷新或清除缓存.
我试过了
CACHE-CONTROL NO-CACHE,NO-STORE
Run Code Online (Sandbox Code Playgroud)
并且
PRAGMA NO-CACHE,NO-STORE
Run Code Online (Sandbox Code Playgroud)
我甚至试过设置EXPIRY 0META标签,这些都没有帮助.虽然它在Chrome和其他浏览器中都能很好地运行,但只有Firefox才有这个问题.
这些是我的标题,由@alex请求
http://localhost/xChange/home.php
GET /xChange/home.php HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
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
Keep-Alive: 115
Connection: keep-alive
Referer: http://localhost/xChange/home.php
Cookie: laobgcidne=yes; eambacidle=inaresh.online@gmail.com
Cache-Control: max-age=0
HTTP/1.1 200 OK
Date: Fri, 10 Dec 2010 08:28:25 GMT
Server: Apache/2.2.11 (Win32) PHP/5.3.0
X-Powered-By: PHP/5.3.0
Cache-Control: no-cache, must-revalidate
Expires: Sat, 26 Jul …Run Code Online (Sandbox Code Playgroud) 您好我在那里开发了一个动态Web应用程序,它使用Ajax从数据库中获取数据并使GUI保持最新,但在使用IE8进行测试时,我遇到了缓存问题.
我在webmvc-config.xml文件中使用以下代码来阻止浏览器进行缓存:
<mvc:annotation-driven />
<mvc:interceptors>
<bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptors>
并且它完全按照预期工作,但问题是现在浏览器显然没有缓存任何东西.我想知道的是如何修改该xml代码,以便它适用于Web应用程序的Ajax部分(使用5个Controller文件控制); 所以icon..etc仍然被缓存?这些控制器文件的路径类似于"/ admin/**"
我知道Spring WebContentInterceptor具有诸如"setCacheMappings"和"setPathMatcher"之类的属性,但是我无法在线找到这些在xml配置文件中使用的示例.
任何帮助将非常感激,它真的在我的脑袋...谢谢.可靠的人
我只是在网上搜索,但找不到一个好的答案:
FF的Google页面速度扩展告诉我在我的网站上缓存文件(PHP).因此,我更新了我.htaccess(在我的网站测试版区域)以缓存某些类型的文件:
ExpiresActive On
ExpiresDefault A0
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
在beta区域进行编码时,我注意到由于缓存控制设置,我需要按下F5以获取最新的.css文件.这对我来说并不坏......但用户呢?
因此,当我更新我的网站(或文件过期)时,我可以告诉浏览器重新下载所有文件(如果没有),并使用缓存吗?
如果我可以告诉浏览器,这将是完美的:"嘿,更新时间之前的所有文件都是旧的,请重新下载它们 - 但是更新时间之后的文件没问题,请使用缓存."
我有一个顺序用户空间程序(某种内存密集型搜索数据结构).以CPU周期数量来衡量的程序性能取决于底层数据结构的内存布局和数据高速缓存大小(LLC).
到目前为止,我的用户空间程序被调整为死亡,现在我想知道我是否可以通过将用户空间代码移动到内核(作为内核模块)来获得性能提升.我可以想到以下因素可以改善内核空间的性能......
我向内核专家提出的问题......
谢谢.
以我的理解,这两个指令都意味着缓存服务器将要求原始服务器重新验证来自客户端浏览器的请求。这两个指令之间有什么区别?
我知道有很多类似的问题,但我已经阅读了所有这些问题,但没有一个真正有用.
所以,这是我的问题:
我正在使用retrofit + okhttp从API获取一些数据,我想缓存它们.不幸的是,我没有API服务器的管理员权限,因此我无法修改服务器返回的标头.(目前,服务器返回Cache-control:private)
所以我决定使用okhttp标头欺骗来插入适当的缓存标头.可悲的是,无论我做什么,缓存似乎都不起作用.
我初始化这样的api服务:
int cacheSize = 10 * 1024 * 1024; // 10 MiB
File cacheFile = new File(context.getCacheDir(), "thumbs");
final Cache cache = new Cache(cacheFile, cacheSize);
OkHttpClient client = new OkHttpClient();
client.setCache(cache);
client.interceptors().add(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Response originalResponse = chain.proceed(chain.request());
return originalResponse.newBuilder()
.removeHeader("Access-Control-Allow-Origin")
.removeHeader("Vary")
.removeHeader("Age")
.removeHeader("Via")
.removeHeader("C3-Request")
.removeHeader("C3-Domain")
.removeHeader("C3-Date")
.removeHeader("C3-Hostname")
.removeHeader("C3-Cache-Control")
.removeHeader("X-Varnish-back")
.removeHeader("X-Varnish")
.removeHeader("X-Cache")
.removeHeader("X-Cache-Hit")
.removeHeader("X-Varnish-front")
.removeHeader("Connection")
.removeHeader("Accept-Ranges")
.removeHeader("Transfer-Encoding")
.header("Cache-Control", "public, max-age=60")
//.header("Expires", "Mon, 27 Apr 2015 08:15:14 …Run Code Online (Sandbox Code Playgroud) cache-control ×10
caching ×3
ajax ×2
javascript ×2
php ×2
spring ×2
spring-mvc ×2
.htaccess ×1
android ×1
azure ×1
fetch-api ×1
firefox ×1
http ×1
interceptor ×1
kernel ×1
max-age ×1
mod-expires ×1
okhttp ×1
performance ×1
policies ×1
retrofit ×1
vue.js ×1