似乎无法更新Django中的外部JavaScript文件

时间:2018-03-01 00:23:15

标签: javascript python django

我试图用我的想法来解决初学Django问题 在Django网站上缓存。

我想在加载页面时重新加载javascript文件,但每次加载页面时我都会得到一个旧的缓存版本。

我已经清除了firefox浏览器缓存(通过选项/隐私和安全性) 然后删除然后使用manage.py collectstatic --clear将静态文件重新复制到静态文件目录中。 加载的旧文件当前不再存在于文件系统中,因此这使我相信存在服务器端缓存。麻烦发生在整个网站范围内。

操作系统:Windows 10 64位

我的目录结构:

Mode                LastWriteTime         Length Name
 ----                -------------         ------ ----
d-----        11/6/2017   4:28 PM                adminPanel
d-----        11/6/2017   4:28 PM                blog
d-----        12/4/2017   3:58 PM                common
d-----        11/6/2017   4:28 PM                contactme
d-----        11/6/2017   4:28 PM                DataEntry
d-----        11/6/2017   4:28 PM                demoscene
d-----        11/6/2017   4:28 PM                errors
d-----        11/6/2017   4:28 PM                footer
d-----        11/6/2017   4:28 PM                headerFrame
d-----        11/6/2017   4:28 PM                Include
d-----        11/6/2017   4:28 PM                Lib
d-----        11/6/2017   4:28 PM                libraries
d-----        11/6/2017   4:28 PM                links
d-----        2/22/2018   5:40 PM                MagicFighter
d-----        11/6/2017   4:28 PM                movies
d-----        11/9/2017   4:37 PM                penumbra_site
d-----        9/28/2017   2:42 PM                pictures
d-----        9/28/2017   2:43 PM                radius
d-----       10/20/2017  12:25 PM                REACTFILES
d-----       10/20/2017   3:32 PM                reactTest
d-----         9/8/2017   1:29 PM                Scripts
d-----       12/14/2017  12:16 PM                splashPage
d-----        2/28/2018  11:07 AM                static
d-----         9/8/2017   1:29 PM                tcl
d-----        9/30/2017   5:59 PM                templates
-a----       10/12/2017   7:35 PM              0 blog_data.sql
-a----         9/9/2017   3:09 PM         131072 db.sqlite3
-a----        8/19/2017   3:19 PM            833 manage.py
-a----         9/8/2017   1:29 PM             60 pip-selfcheck.json
-a----        10/1/2017   4:57 PM              0 Run.log

Settings.py

"""
Django settings for penumbra_site project.

Generated by 'django-admin startproject' using Django 1.11.4.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'r!acp5ca#r#x59353gl4)l8t(xrc_%lm@_^u9atn_9&hnoj_j4'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['127.0.0.1','localhost']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'blog',
    'errors',
    'footer',
    'headerFrame',
    'links',
    'libraries',
    'pictures',
    'movies',
    'contactme',
    'demoscene',
    'reactTest',
    'splashPage',
    'radius',
    'MagicFighter',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'penumbra_site.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates')
        ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'penumbra_site.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'blog_data',
        'USER': 'static',
        'PASSWORD': 'topsecret',
        'HOST':'',
        'PORT':'',
    }
}
if not DEBUG:
    CACHES = {
        'default': {
            'BACKEND':        'django.core.cache.backends.memcached.MemcachedCache',
            'LOCATION': '127.0.0.1:11211',
        }
    }
else:
    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
        }
    }
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-  validators

    AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME':    'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME':    'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME':    'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'America/Los_Angeles'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = str(BASE_DIR) + '\\static\\'
SUBDIRECTORY_NAME = str(BASE_DIR) + '\\static\\common\\'
COLLECTION_AREA = str(BASE_DIR) + '\\common\\'
STATICFILES_DIRS = [
    os.path.join(SUBDIRECTORY_NAME),
    os.path.join(COLLECTION_AREA)
]

除了缓存问题之外,一切似乎都正常。我在这里错过了标准的开发程序吗?

0 个答案:

没有答案