static-files

ReactJS: How to prevent browser from caching static files?

走远了吗. 提交于 2020-01-02 05:24:11
问题 I'm working on my project using ReactJS and I use create-react-app to create my app. After building project, I use my server to serve the build folder. And when I update my app, the browser of user still uses the old version of my app because it caches the static files (js, css). So is there any way to prevent browser from caching static files ? Thank you ! 回答1: TLDR: You will want to send caching instructions via HTTP headers. The Cache-Control header has several directives to control cache

What's the better approach: serving static files with Express or nginx?

限于喜欢 提交于 2019-12-31 20:46:46
问题 I'm building a Node.js applications and I'm using nginx as a reverse proxy. My application has some static files I need to serve and a Socket.io server. I know that I can serve static files directly with Express (using express.static middleware). Also I can point nginx directly to the directory where my static files are located, so they would be served by nginx. So, the question: which one is the better approach? Which pros and cons can I face while using each approach? 回答1: for development:

python built in server not loading css

↘锁芯ラ 提交于 2019-12-29 07:55:27
问题 when i runserver the django admin is missing css.The web console says that style sheet was not loaded because its MIME type,"application/x-css", is not "text/css". This is my settings.py file Django settings for mysite project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'C:/djangorevision/mysite/sqlite3.db', database 'USER': '', # Not used with sqlite3.

Serving static files while running Django&mod_wsgi on Apache 2.2

陌路散爱 提交于 2019-12-24 23:45:22
问题 I have changed my Apache 2.2's httpd.conf #Serve static files Alias /static/ "E:\Python\Django\carlsblog\static\" <Directory "E:\Python\Django\carlsblog\static"> Order allow,deny Options Indexes Allow from all IndexOptions FancyIndexing </Directory> #Start mod_wsgi as default handler WSGIScriptAlias / "E:\Python\Django\carlsblog\django.wsgi" <Directory "E:\Python\Django\carlsblog"> Allow from all </Directory> and my app can be successfully run, only the static files cannot be accessed, a 404

Media files are served, static files aren't

早过忘川 提交于 2019-12-24 11:29:31
问题 I'm stuck due to an evergreen issue, static files not served. Conversely the files placed in the MEDIA_ROOT subtree get served correctly under MEDIA_URL . Stripped settings.py : DEBUG = True STATIC_URL = '/static/' STATIC_ROOT = '/home/foo/devel/static' MEDIA_URL = '/media/' MEDIA_ROOT = '/home/foo/devel/media' # the following is deprecated but is it seems grappelly requires it ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/" STATIC_FILES = () STATICFILES_FINDERS = ( 'django.contrib.staticfiles

How to use try_files with 2 or more roots

孤街浪徒 提交于 2019-12-23 17:17:55
问题 I have looked hi and low and found no such implementation and am wondering if what I am trying is even possible. I have 3 relative paths that serve up static content: Path1: /usr/local/www/style1/static/... Path2: /usr/local/www/style2/static/... Path3: /usr/local/www/style3/static/... The 3 different roots are static unto themselves but the content from /static on down is only semi-static (might be a bit different depending on the exact file being served up and may exist in one path and not

Microsoft.Owin.StaticFiles works in console host but I get a 404 in IIS on file requests

独自空忆成欢 提交于 2019-12-23 07:55:55
问题 I have Microsoft.Owin.FileServer (v2.1.0) set up in my Owin pipeline, and setting up FileServerOptions with EnableDirectoryBrowsing = true works great for showing the directory contents in both my console host and iisexpress. It's when I try to view a particular file (so, the StaticFiles part) I have problems in iisexpress. Still works great in the console host, but in iisexpress I get a 404: HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed,

Sharing static resources between maven modules

拈花ヽ惹草 提交于 2019-12-22 03:46:31
问题 I have a Maven project with a parent-pom project and 3 maven-module projects in it. 2 of the modules are Java-EE web apps that compile into WAR files. 1 of the modules contains common JAVA code which is shared between the 2 other projects. Sharing the JAVA code was easy. The question I have is how to a share common static resources such as JavaScript, CSS, and image files without duplicating them in each web module? I would also like to do it in such a way that I can continue running the web

Serve html file in nodejs server

。_饼干妹妹 提交于 2019-12-22 00:58:28
问题 I've been doing fine until I try to separate my code into routes, controllers and etc. Now I'm getting an error when I try to load the html file. When I go to the link http://localhost:3000/ I'm getting this error Error: ENOENT: no such file or directory, stat '/views/index.html' This is my routes.js code module.exports = function (app) { var userController = require('../controllers/userController'); // app.use(require('express').static('../app/views/index.html')); app.get('/', userController

Render JavaScript to HTML in Python?

拟墨画扇 提交于 2019-12-21 20:24:12
问题 What My web-app is made dynamic through Google's AngularJS. I want static versions of my pages to be generated. Why Web-scrapers like Google's execute and render the JavaScript; but don't treat the content the same way as their static equivalents. References: Does heavy JavaScript use adversely impact Googleability? (Programmers StackExchange) Making AJAX Applications Crawlable (Google Documentation for webmasters) How Not sure exactly how—which is why I'm asking—but I want to access the same