标签: cache-expiration

Rails 4.0 expire_fragment/cache expiration无法正常工作

我一直在尝试使用rails的缓存功能,但我无法使一些缓存片段过期,尽管它们似乎已过期.使用rails教程网站中指出的"俄罗斯娃娃缓存",我正在使用此配置

<% cache "all_available_releases" do %>
 <% @releases.each do |release| %>
  <% cache(release) do %>
   <html code with>
   <%ruby code @release.name blah blah blah%>
  <%end%>
 <%end%>
<%end%>    
Run Code Online (Sandbox Code Playgroud)

我使用release_controller.rb控制器中的外部缓存到期,我使用expire_fragment("all_available_releases")来使片段到期.我在控制器的每个更新或删除或添加条目的方法中使用它.

这是WEBrick的日志,虽然expire片段已经注册,但5行之后读取并使用过期片段,而不应该.此示例是在销毁调用之后.

Processing by ReleasesController#destroy as HTML
  Parameters: {"authenticity_token"=>"***/***/********************+********=", "id"=>"2"}
  Release Load (0.1ms)  SELECT "releases".* FROM "releases" WHERE "releases"."id" = ? LIMIT 1  [["id", "2"]]
   (0.1ms)  begin transaction
  SQL (2.0ms)  DELETE FROM "releases" WHERE "releases"."id" = ?  [["id", 2]]
   (148.0ms)  commit transaction
Expire fragment views/all_available_releases (0.1ms)
Redirected to http://127.0.0.1:3000/releases
Completed 302 Found in …
Run Code Online (Sandbox Code Playgroud)

ruby caching ruby-on-rails cache-expiration

28
推荐指数
1
解决办法
5587
查看次数

指定静态文件缓存的到期日期

当我测试我的网站SpeedTest时,我看到很多过期没有指定错误.你可以在这个页面看到.

我将此代码添加到我的.htaccess文件中

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
Run Code Online (Sandbox Code Playgroud)

但没有改变.你可以给我一个建议吗,我可以为静态文件指定过期日期吗?

服务器:Linux - Apache

apache caching cache-expiration

15
推荐指数
3
解决办法
3万
查看次数

我的redis键不会过期

当生存时间达到0时,我的redis服务器不会删除密钥.

这是一个示例代码:

redis-cli
>SET mykey "ismykey"
>EXPIRE mykey 20
#check TTL
>TTL mykey
>(integer) 17
> ...
>TTL mykey
>(integer) -1
#mykey chould have expired:
>EXISTS mykey
>(integer) 1
>#oh still there, check its value
>GET mykey
>"ismykey"
Run Code Online (Sandbox Code Playgroud)

如果我通过redis检查信息返回,则表示0个密钥已过期.

任何的想法?

谢谢.

ttl redis cache-expiration

14
推荐指数
1
解决办法
2万
查看次数

Nginx 字体兑现

我拼命想找到一种方法来设置 nginx 中字体的到期日期,以在移动设备上进行优化。

我对 ttf 字体感兴趣。

我有 mime.types 作为休闲:

application/font-woff                 woff;
application/vnd.ms-fontobject         eot;
application/x-font-ttf                ttc ttf;
font/opentype                         otf;
image/svg+xml                         svg svgz;
Run Code Online (Sandbox Code Playgroud)

在 Nginx 上,我尝试了在网络上找到的所有解决方案,但均无济于事:

尝试#1:

location ~* \.(?:eot|woff|woff2|ttf|svg|otf) {
access_log        off;
log_not_found     off;
expires           365d;
add_header        Cache-Control "public";
add_header        Access-Control-Allow-Origin *;
types     {font/truetype ttf;}
}
Run Code Online (Sandbox Code Playgroud)

失败 否 到期:

Request URL: http://localhost:3001/static/media/Poppins-Regular.8081832f.ttf
Request Method: GET
Status Code: 200 OK
Remote Address: [::1]:3001
Referrer Policy: strict-origin-when-cross-origin
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/x-font-ttf
Date: Thu, 01 Apr 2021 18:33:55 GMT
ETag: W/"60660e52-269f0"
Last-Modified: …
Run Code Online (Sandbox Code Playgroud)

fonts caching nginx http-headers cache-expiration

7
推荐指数
1
解决办法
4006
查看次数

JCache (JSR107) 是否允许不同条目的不同到期持续时间?

假设我想缓存昂贵的方法调用的结果。这些缓存条目应具有不同的到期持续时间(又名 TTL)。如果将条目放入同一个 Cache 实例中,这对 JCache 是否可行?

我知道我可以为每个缓存分配不同的 ExpiryPolicy。但是我想知道是否可以单独为 CacheEntry 分配到期持续时间。

JCache 支持吗?如果是这样,我会很感激这个代码示例的链接。这个问题的范围纯粹是 JCache,没有任何特定于实现的功能。

java caching jcache cache-expiration

5
推荐指数
1
解决办法
1106
查看次数

将缓存Redis过期设置为1年

如何设置Redis Cache的有效期为1年?

我试图long将xml配置上的值设置为:31556952000(1年),但是随后它捕获到一个异常,该异常是Integer类型无法将值识别为Integer。我尝试在Google上进行搜索,结果显示Integer最大值不超过2147483647,这意味着,如果设置为Integer最大值,则只会使我的缓存在24天后过期。

这是我的applicationContext.xml(我省略了不必要的代码):

    ...
    <cache:annotation-driven />

    <bean id="redisCacheMap" class="java.util.HashMap">
        <constructor-arg index="0" type="java.util.Map">
            <map key-type="java.lang.String" value-type="java.lang.Integer">
                <entry key="ruleCache" value="86400"/>
            </map>
        </constructor-arg>
    </bean>
    ...
Run Code Online (Sandbox Code Playgroud)

上面的代码配置为将过期设置ruleCache为仅1天(86400以毫秒为单位)。

有可能这样做吗?谢谢。

caching spring-mvc redis cache-expiration

2
推荐指数
1
解决办法
4939
查看次数

集合中的老化对象

我希望能够在Collection中对对象进行老化.

例如,我可以将字符串放在HashSet中.

  1. 我想将字符串放入HashSet时的时间戳关联起来.
  2. 我希望String比从HashSet中删除时间X更早.
  3. 我希望能够说"触摸"一个字符串并更新它在集合中插入的时间.

因此,我可以通过跟踪每个String然后运行清理Thread并从Collection中清除String(如果它早于某个时间量)来完成此操作.

但是我正在寻找:

  1. 这是一个聪明的方式来做到这一点.
  2. 一个现有的开源java组件,它实现了这一点.

谢谢.

java queue collections priority-queue cache-expiration

2
推荐指数
2
解决办法
773
查看次数

如何使用xPages强制更新设计更改到客户端?

我正在使用xPages建立一个网页,我正在对脚本和设计进行不断的更改,这包括服务器和客户端javascript,样式表和图像更改.

每次我更改javascript或样式表时,我都希望在webbrowser中看到我的更改,并且我还希望我的用户在访问网页时获得最新的更改.

我知道我可以使用Shift-Reload,或CTRL重新加载并清除我的webbrowser缓存.而且我也知道我可以更改对象的到期日期,但我想要一种更平滑,更好的控制方式来做到这一点.

寻找任何形式的最佳实践.

谢谢

托马斯

javascript stylesheet lotus-domino cache-expiration xpages

0
推荐指数
1
解决办法
3022
查看次数

从 ets 表中删除日期戳早于 10 秒的所有记录

ets在一个长生不老药应用程序中有一个设置表。我需要清理其 updated_at 字段超过 10 秒的记录。有没有一种方法可以设置到期时间或手动完成而不遍历所有记录?我根据大于给定时间的时间戳匹配记录。

示例记录:

key: key_1
record: %{id: key_1, updated_at: ~N[2018-12-19 10:08:47.803075]}
Run Code Online (Sandbox Code Playgroud)

到目前为止我有这个代码

def clean_stale(previous_key) do
  if previous_key == :"$end_of_table" do
    :ok
  else
    device = get(previous_key)
    next_key = :ets.next(__MODULE__, previous_key)
    if NaiveDateTime.diff(NaiveDateTime.utc_now, device.last_recorded_at) > 10 do
      remove(device.id)
    end
    clean_stale(next_key)
  end
end
Run Code Online (Sandbox Code Playgroud)

erlang elixir ets cache-expiration data-cleaning

0
推荐指数
1
解决办法
516
查看次数