I'm not sure if this is a Django-specific issue but right now I see it in my project.
Because browsers tend to cache favicon and I have changed them for my website, I came up with a trick to force anyone who have visited my site before to receive the new icons, adding "?" followed by some random characters to the image file name, so currently it is like this:
<link rel="icon" type="image/png" sizes="32x32" href="{% static 'images/favicons/favicon-32x32.png?v=Gv6qnaoWO5' %}">
Now the issue is, the favicon is not loading and when I check the source I see this:
<link rel="icon" type="image/png" sizes="32x32" href="/static/images/favicons/favicon-32x32.png%3Fv%3DGv6qnaoWO5">
and when I click on the above link, I get 404 error from django.views.static.serve. If I remove the "?" and rest of characters, everything works fine.
If memory serves, this is normal encoding of special characters and the web server should decode it, but this is not happening on Django's built-in server.
So, is there a fix for this, or I should wait until moving the site to production?
static takes a filename, and builds the URL. A filename doesn't have query parameters. Add the query parameters to it after the fact:
href="{% static 'images/favicons/favicon-32x32.png' %}?v=Gv6qnaoWO5">
Related
I have a github pages static website at norricorp.github.io/sveltekit. The root of the site is sveltekit. (I also have an unrelated website at norricorp.github.io). The site is built using sveltekit.
Entering the website, I get the following error in the console.
Loading module from “https://norricorp.github.io/sveltekit/_app/start-248e1695.js” was blocked because of a disallowed MIME type (“text/html”).
If I use the navigation (which does as expected) I get the following errors
GEThttps://norricorp.github.io/sveltekit/_app/assets/start-a8cd1609.css
[HTTP/2 404 Not Found 15ms]
more like this then
Loading module from “https://norricorp.github.io/sveltekit/_app/start-248e1695.js” was blocked because of a disallowed MIME type (“text/html”). about
I suspect the problem lies in the svelte.config.js file
kit: {
target: '#svelte',
paths: {
base: '/sveltekit',
assets: '/sveltekit'
},
adapter: adapter({
pages: 'build', // path to public directory
assets: 'build', // path to public directory
fallback: null
})
}
Initially, paths was set ‘/’ or ‘./’ which caused navigation to use either norricorp.github.io/about(does not exist) or norricorp.github.io/sveltekit/about/about (same again). But navigation does now work with the above values but no formatting.
The generated index.html file is within the repo on the gh-pages branch.This looks correct.
<link rel="modulepreload" href="/sveltekit/_app/start-248e1695.js">
<link rel="modulepreload" href="/sveltekit/_app/chunks/vendor-111805ed.js">
<link rel="modulepreload" href="/sveltekit/_app/chunks/paths-45dac81d.js">
<link rel="modulepreload" href="/sveltekit/_app/pages/__layout.svelte-1d5e7523.js">
<link rel="modulepreload" href="/sveltekit/_app/pages/index.svelte-fdf5a78d.js">
<link rel="stylesheet" href="/sveltekit/_app/assets/start-a8cd1609.css">
<link rel="stylesheet" href="/sveltekit/_app/assets/pages/__layout.svelte-8ddef586.css">
I have cleared the browser cache. I have also created another github pages project under a different account so that it was a top level domain. Same result.
So the browser is looking in the right place, the files are there in the correct branch of the github repo but the browser is not finding them. Is github pages not serving these?
I had deleted the .nojekyll file and forgot to replace it .....
I just moved my static website to AWS S3 + Cloudfront & Route 43. Once I deployed my site I ran Lighthouse & Pagespeed Insights and I'm getting "Preconnect to required origins Error!".
Before I moved my site I was not getting this error, so I'm thinking it has something to do with my AWS configuration. Here is my preconnects in my index.html file.
<link rel="preconnect" href="//www.google-analytics.com" crossorigin>
<link rel="preconnect" href="//fonts.googleapis.com" crossorigin>
<link rel="dns-prefetch" href="//fonts.googleapis.com">
I'm not connecting to any other 3rd parties, only Analytics & Google font. Am I missing a preconnect to cloudfront? I searched for a couple days online and have not found anything yet, so I'm here.
If you make requests directly to your Cloudfront domain, then you will need to preconnect to it too.
I'm not positive but should your href tag values start with https?
I can not preview a html file in webstorm 9.0.1 when I run it, it shows web page is not available because in addressbar it shows localhost:63342/---project folder.---. How can I access from local harddisk html file.
And, another question can I preview html in google chrome/firefox as docable?
To access http://localhost you need to have running local server (like XAMPP or WAMPP). If you have no localhost server (or you have no idea if that thing exist in your computer) than you can't access http://localhost. That means any *.php file will be not usable.
If you are font-end developer, you don't need server. You can access your *.html files directly: file:///C:/path/to/file.html (in browser site url box). Also, for any external sources to work, path to that file must be relative:
//C://myProject
myProject
|-index.html
\
css
|-styles.css
\js
|-functions.js
You enter to browser url bar: file:///C://myProject/index.html
Your index.html looks like this:
<html>
<head>
<script src="js/functions.js"></script>
<-- WRONG:
<script src="http://localhost/js/functions.js"></script>
<script src="C:/myProject/js/functions.js"></script> // valid, but better to avoid
-->
</head>
</html>
To preview HTML file on disk (using file:/// protocol) in WebStorm, hold Shift when choosing a browser
I have a Django 1.4 webapp using storages.backends.s3boto.S3BotoStorage as the file storage backend to serve static files from AWS S3.
Everything works -- except admin static files. On inspection of the admin page source, it's clear the problem is coming from the admin static file URLs, for example for the admin's base.css stylesheet:
<link rel="stylesheet" type="text/css" href="https://watchdog_staticfiles.s3.amazonaws.com/admin/css/base.css?Signature=sFKzAavHHKYdJQVDGTwwSAyrrjc%3D&Expires=1387824617&AWSAccessKeyId=AKIAJAYZSKEJIVD52OCQ" />
The problem is the presence of the Signature, Expires, and AWSAccessKeyId URL parameters. With these there, the link leads to an access denied response from AWS. Without them, i.e. just going to the plain URL https://watchdog_staticfiles.s3.amazonaws.com/admin/css/base.css, there's no problem (as the file is set to be publicly readable).
These signature/expires/etc parameters are not being added to static URL links in my main webapp, just within the admin.
So my question is -- where are they coming from and how do I get rid of them?
So, I have 2 servers that serve pages. I am running ColdFusion on Windows Server 2003 with IIS6. I created the site and synchronized the files between the 2 servers. In the right hand side of my site is a popup div for the search. On Server1 in IE6, this div works perfectly, on server 2 it gets cut off. Due to the synchronization software used, I cannot have different files on the two servers.
Any help is appreciated.
Thanks
Your IE6 stylesheet if failing to load for the second site.
This URL works:
http://www.sdccc.org:81/styles/03-ie6-fix.css
This URL doesn't:
http://www.sdccc.org:82/styles/03-ie6-fix.css
Oddly, this only appears to occur in IE itself - verifying the links above in Chrome and both of them work.
Update:
The port 82 server is returning Content-Encoding: gzip and Vary: Accept-Encoding headers - the port 81 server is not.
I suspect this is a bug with IE not accepting the gzipped content?
Two equal documents in the same browser has to produce the same page:
As I can see the document produced by each servers are practically the same, except for the CSS stylesheet:
<LINK href="./sd81_files/01-ejungle.css" type="text/css" rel="stylesheet">
and
<LINK href="http://www.sdccc.org:82/styles/01-ejungle.css" type="text/css" rel="stylesheet">
Yes, you can say that the files are the same, but when I saved the files into my computer, the second one did not arrive. Check the link and try again.
I finally figured it out! It seems that 2 image files, for some reason, didn't have read permissions on them on the second server:
/images/search_04_drop_04-ie6.png
/images/search_jason_04-ie6.png
updated the permissions and it started working.
Thanks for all of your help in this.