如何强制刷新rails中的每个页面

时间:2014-04-27 20:19:05

标签: javascript ruby-on-rails-4 web

我似乎无法弄清楚如何在我的rails应用程序中成功转换缓存。我制作的网站是http://www.liftlineclothing.com,在使用导航栏点击服装页面后,除非您在浏览页面后刷新页面,否则不会显示。同样,当导航回主页时,除非您刷新页面,否则不会显示用于获取文本的Javascript。

我很确定这是一个缓存问题,但如果有人有想法,我会非常感激。我已经进入配置文件并将rails cache更改为false。

更新

这是javascript

var pausebetweenmsg=10 //customize pause in miliseconds between each message showing up  
(3000=3 seconds)
var glidespeed=50 //customize glide speed in pixels per frame.

var curobjindex=0

function actualstyle(el, cssproperty){
if (el.currentStyle)
return el.currentStyle[cssproperty]
else if (window.getComputedStyle){
var elstyle=window.getComputedStyle(el, "")
return elstyle.getPropertyValue(cssproperty)
 }
}

function collectElementbyClass(){
var classname="glidetext"
glidearray=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
glidearray[inc++]=alltags[i]
}
if (glidearray.length>0)
onebyoneglide()
}

function onebyoneglide(){
if (curobjindex<glidearray.length)
glidetimer=setInterval("glideroutine()",50)
}

function glideroutine(){
if (parseInt(actualstyle(glidearray[curobjindex], "left"))<0)
glidearray[curobjindex].style.left=parseInt(actualstyle(glidearray[curobjindex], "left"))+50+"px"
else{
glidearray[curobjindex].style.left=0
curobjindex++
clearInterval(glidetimer)
setTimeout("onebyoneglide()", pausebetweenmsg)
}
}

if (window.addEventListener)
window.addEventListener("load", collectElementbyClass, false)
else if (window.attachEvent)
window.attachEvent("onload", collectElementbyClass)
else if (document.getElementById)
window.onload=collectElementbyClass

这会将主页上的文本从导航到其他页面时无效的主页发送到页面上。您还必须刷新主页。

服装javascript,即由ecwid处理。一旦我找到他们正在使用的特定javascript,我就会更新。

1 个答案:

答案 0 :(得分:0)

这看起来不像是一个缓存问题,看起来Turbolinks正在弄乱你的内容加载。如果它符合您的需要,请阅读禁用/解决Turbolinks或尝试https://github.com/kossnocorp/jquery.turbolinks。打开Chrome Inspector后,您可以看到点击导航链接并未实际重新加载您的网页,因此您的$(document).ready活动实际上并未触发第一页。

此外,如果我按照您的页面链接,刷新,然后单击任何导航链接,您的页面开始每秒生成1个JS错误。

Uncaught com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read property 'userAgent' of null 0.js:3836
1398638731162: EcwidEntryPoint: uncaught exception com.google.gwt.core.client.JavaScriptException:
(TypeError) : Cannot read property 'userAgent' of null