HTTP-HTTPS (stylesheets, js, css-sprites, etc.) Reboot

This question has nothing to do with a mixed content error. About the launch of the site. When I switch from http://example.com to https://example.com , I noticed that css / js / etc is reloading as I use the root relative paths :.

Using the http sniffer, I see that the browser considers https://www.example.com/_css/main.css different from http://www.example.com/_css/main.css (it is not). Thus, the same exact content is downloaded twice, making the site look slower, moving from http to https (if the user does not have both versions already cached).

Is there any way to stop this? The user will almost always encounter a version of the site other than ssl, since there is a script that will wait for the HTTP content to load, what can force the https version to the users cache? Or I just use absolute paths (https://www.example.com/_css/main.css) on any page and on every css image (only 2 I use sprites). Or are we just living with this? Thank.

+5
source share
5 answers

Using http sniffer, I see that the browser thinks https://www.mysite.com/_css/main.css is different from http://www.mysite.com/_css/main.css (it is not).

. , .

( 301) , SSL.

?

.

, ssl, script, , http, https- ?

. , URL- URL-.

(https://www.mysite.com/_css/main.css) css ( 2 ).

, .

?

.

+4

.

  • . , http https, https .

    <base href="https://example.com/" />

  • SSL, Apache ( SSL)

    Redirect permanent / https://example.com/login

+1

.htaccess RewriteRule https ; , http- html, ( ), , .

0

, .

<link rel="stylesheet" href="http://domain.com/style.css">
<link rel="stylesheet" href="https://domain.com/style.css"> 

<link rel="stylesheet" href="//domain.com/style.css">

.

0

, :

<link rel="stylesheet" type="text/css" href="//mysite.com/_css/main.css" />

. :

Can I change all my http: // links only to //?

-1
source

All Articles