Javascript文件缓存问题

Javascript file caching issue

本文关键字:问题 缓存 文件 Javascript      更新时间:2023-09-26

我遇到了一个非常奇怪的问题,我无法找到根源。

我有一个正确加载并执行的文件:main.js,代码为:

$(function() {
$('.navigation a').click(function(ev) {
    currentTab = $(this).find('.active');
    newTab =  $(this).attr('name');
    $('.active').removeClass('active');
    $(this).addClass('active');
 });
});

这非常有效。但是如果我把代码改成:

$(function() {
$('.navigation a').click(function(ev) {
    currentTab = $(this).find('.active');
    newTab =  $(this).attr('name');
    newTab =  $(this).attr('name');
    newTab =  $(this).attr('name');
    newTab =  $(this).attr('name');
    newTab =  $(this).attr('name');
    $('.active').removeClass('active');
    $(this).addClass('active');
 });
});

当我直接通过浏览器查看文件时,它会恢复为:

$(function() {  $('.navigation a').click(function(ev) {     currentTab = $(this).find('.active');       newTab =  $(this).attr('name');     console.log(currentTab);        console.log(currentTab);        console.log(currentTab);        $('.active').removeClass('active');     $(this).addClass('active'); });});
������������������������������������������������������������������������������

控制台日志错误为:

未捕获的SyntaxError:意外的令牌ILLEGAL(第2行)

它工作得很好,但似乎一旦我中断了一定数量的行,它就会损坏并恢复到旧的缓存文件。根据我自己的测试,如果文件总共有12行,它就可以工作了。如果它大于12,则会断开,如上所示。

我试过:

  • CTRL+F5

  • 隐姓埋名

  • 3种不同的浏览器

  • 2 IDE的

  • 重新启动我的计算机

  • 已清除缓存,已禁用缓存。

完全迷路了,有什么建议吗?谢谢你抽出时间。

我找到了问题的原因。

/etc/httpd/conf/httpd.conf

有一条线路

#启用发送文件关闭

这一行必须取消注释。