标签: static-content

拒绝使用查询字符串来版本化静态文件?

似乎为了强制用户刷新缓存的静态文件(例如,.css,.js),一些站点(例如,stackoverflow.com)将查询字符串附加到文件的末尾.例如:

<link rel="stylesheet" type="text/css" href="http://sstatic.net/stackoverflow/all.css?v=9ea1a272f146">
Run Code Online (Sandbox Code Playgroud)

我认为这是一个好主意,我也倾向于开始这样做.但是,我听说有缺点,例如代理不能正确缓存文件,如果存在查询字符串.

这种版本控制的缺点是什么?

versioning caching static-content

6
推荐指数
1
解决办法
1131
查看次数

Express:如何将font-awesome作为静态内容提供?

我使用express来在我的网站上提供静态内容,我想要合并FontAwesome(npm install font-awesome).但是在Font-Awesome的css中,字体文件的链接附有一个查询字符串,其中包含表达不明白的版本信息.

有没有人遇到这个并找到了修复?是否有一种简单的方法可以使表达式忽略静态内容的qs?

var express = require('express')
var app = express()

app.use('/static', express.static('./node_modules/font-awesome/css'))
app.use('/static', express.static('./node_modules/font-awesome/fonts'))

// response 200 | /static/font-awesome.min.css
// error 404    | /static/fontawesome--webfont.woff?v=4.6.3
Run Code Online (Sandbox Code Playgroud)

更新 为@DenysSéguret指出我们并不像我想象的那样.实际的要求是/fonts/fontawesome--webfont.woff?v=...

app.use('/fonts', express.static('./node_modules/font-awesome/fonts'))
Run Code Online (Sandbox Code Playgroud)

static-content node.js express

6
推荐指数
1
解决办法
4615
查看次数

用于静态站点的RSS

我有一个网站,deanvmc.me,我用来自学HTML,CSS和JavaScript.该网站是故意静态的,以剥夺我的学习承受骨头(我觉得最好的学习方式).我使用github作为主机进一步锁定我静态生成的内容.

我想在这个网站上放一些文章和教程,并觉得为两者提供RSS源会很好./ Articles和/ Tutorials目录将用于分别以/ Articles /和/ Tutorials /形式列出实际帖子的内容.

我环顾四周,但我找到的任何教程似乎都依赖于我使用的主要CMS引擎之一,我不知道该做什么.

我的理解是RSS比CMS引擎更长,所以我的问题是,是否有可能联合我的静态网站?

rss html5 static-content

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

在IIS中设置"过期Web内容"常见的http响应标头

我们有一个相当大量的IIS7.0站点(每天约100万个请求),其中很多是Images/CSS/JS.

作为一种减少这种情况的快速方法,我正在考虑设置常见的http响应标头,以便将来某个固定的日期方式使网络内容过期,并且想知道我们可以通过这种方式获得哪些可能的缺点.

查看设置此内容所导致的web.config更改,它添加:

<staticContent>
    <clientCache cacheControlMode="UseExpires" cacheControlMaxAge="1.00:00:00" httpExpires="Thu, 01 Oct 2020 00:00:00 GMT" />
</staticContent>
Run Code Online (Sandbox Code Playgroud)

我担心的是,如果我们想在设置之后更改其中一个CSS/JS/Images,客户端就不会接收更改,虽然图像可能不会改变,但CSS/JS肯定会.这是否意味着我们应该只设置这对包含文件夹图像?或者这是否意味着我们需要为CSS/JS引入版本化的URL?

iis caching static-content

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

如何在AppFog中使用Apache提供静态内容(WSGI Python应用程序)

我正在使用AppFog PaaS系统几天,我喜欢它,它可能是我测试过的最好的PaaS系统(之前我使用过其他3个),但没有找到有关如何提供静态服务的信息前端Web服务器的内容(Apache https或nginx)我不确定使用的服务器是什么.

我的应用程序是一个带有CherryPy的Python WSGI,并且在AppFog中运行得很好,但我不想使用CherryPy来提供静态内容,我认为Apache httpd或nginx是一个更好的选择.

python apache wsgi static-content appfog

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

GrizzlyWebServer + Spring + Jersey +提供JAR内的静态内容

我正在尝试使用Grizzly来部署基于Jersey-Spring的REST API com.sun.grizzly.http.embed.GrizzlyWebServer.我也想使用相同的服务提供静态内容.这是我有的:

String host = "localhost";
int port = 8081;

// For jersey + Spring
ServletAdapter jAdapter = new ServletAdapter("jersey");
jAdapter.setContextPath("/api");        
jAdapter.setServletInstance(new SpringServlet());
jAdapter.addContextParameter("contextConfigLocation", "classpath:spring-context.xml");
jAdapter.addServletListener("org.springframework.web.context.ContextLoaderListener");
jAdapter.addServletListener("org.springframework.web.context.request.RequestContextListener");              

// create GrizzlyWebServer
GrizzlyWebServer grizzlyServer = new GrizzlyWebServer(host, port, "webapp", false);

// add jersey adapter
grizzlyServer.addGrizzlyAdapter(jAdapter, new String[]{"/api"}); 

// start server
grizzlyServer.start();

System.out.println("Start running server(host: " + host + ",port: " + Integer.toString(port));
System.out.println("Press any key to stop the server.");

// hang on
System.in.read();

// stop
grizzlyServer.stop();
Run Code Online (Sandbox Code Playgroud)

"Jersey Adapter"工作正常但我无法获取"webapp"文件夹中存在的静态内容(404错误).

我的项目文件夹结构如下:

GrizzlyTest …
Run Code Online (Sandbox Code Playgroud)

java rest jersey grizzly static-content

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

允许 nginx 服务器中的 POST 请求获取静态内容

我们有一个 Angular 应用程序部署到 DigitalOcean => Ubuntu => Nginx, => www 文件夹,它接受所有 GET 请求。我们调用一些第三方 API,作为响应,第三方通过 POST 访问我们的端点。但 nginx 不允许。它给出了 405 消息。我不是 nginx 专家,有人可以提供一些建议吗?

<html>
    <head>
        <title>405 Not Allowed</title>
    </head>
    <body bgcolor="white">
        <center>
            <h1>405 Not Allowed</h1>
        </center>
        <hr>
        <center>nginx/1.14.0 (Ubuntu)</center>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

nginx static-content angular

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

django-pipeline和s3boto存储似乎不能一起工作

我正在尝试使用django-pipeline-1.1.27和s3boto来压缩和过滤静态文件,然后将它们上传到s3存储桶.如果我只是使用:

PIPELINE_STORAGE = 'pipeline.storage.PipelineFinderStorage'
Run Code Online (Sandbox Code Playgroud)

然后它工作,我得到一个静态文件夹,其中包含我配置的漂亮版本文件.我一切换到

PIPELINE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
Run Code Online (Sandbox Code Playgroud)

我明白了

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_manager(settings)
  File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/my/virtual/env/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/my/virtual/env/lib/python2.7/site-packages/pipeline/management/commands/synccompress.py", line 39, in handle
    packager.pack_stylesheets(package, sync=sync, force=force)
  File "/my/virtual/env/lib/python2.7/site-packages/pipeline/packager.py", line 52, in pack_stylesheets
    **kwargs)
  File "/my/virtual/env/lib/python2.7/site-packages/pipeline/packager.py", line 60, in pack
    package['output'], package['paths'])
  File "/my/virtual/env/lib/python2.7/site-packages/pipeline/versioning/__init__.py", line …
Run Code Online (Sandbox Code Playgroud)

python django static-content django-pipeline

4
推荐指数
1
解决办法
2089
查看次数

如何使用Websphere Liberty显示HTML文件?

我有静态HTML页面.使用Apache服务器(通过XAMPP)我曾经将我的HTML文件放在htdocs文件夹中,并且可以通过localhost URL访问它们.

我不确定如何使用Websphere Liberty服务器执行此操作.假设我有以下HellWorld HTML示例index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>HellWorld</title>
  </head>    
  <body>
    <p>HellWorld</p>
  </body>
</html> 
Run Code Online (Sandbox Code Playgroud)

如何通过Liberty在浏览器中显示此HTML页面?

html apache static-content websphere-liberty

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

为什么忽略 nginx 我的子路径位置指令的“auth_basic off”?

Nginx(docker image1.17.2)需要对子路径进行基本身份验证。尽管我的配置另有说明https://example.org/subpath

//  /etc/nginx/conf.d/mysetup.conf

ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

server {
    listen 443 ssl;
    server_name example.org;
    server_tokens off;

    ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    access_log /var/logs/nginx/example.org.access.log;
    error_log /var/logs/nginx/example.org.error.log info;

    root /var/www/domains/example.org/stage_root/;        

    location / {
        auth_basic "example.org server";
        auth_basic_user_file /var/htaccess/htaccess_example.org;
    }
    location /subpath {
        auth_basic off;
        root /var/www/domains/example.org/;
    }
}
Run Code Online (Sandbox Code Playgroud)

一些事实:

  • nignx 接受我的conf而不发出警告
  • 有更多的域服务(都在类似的server指令中)和上游丛。
  • docker 镜像是docker-compose其自己网络设置的一部分(nginx 是网关)
  • 提供正确的内容:/var/www/domains/example.org/subpath/
  • 注释掉全局auth_basic会禁用身份验证请求

到目前为止我尝试过的:

  • 将 auth_basic 设置从该location /块移至该server …

nginx basic-authentication static-content nginx-location

4
推荐指数
1
解决办法
2788
查看次数