Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] kompresja Gzip dla plików żródłowych.
pieto
post
Post #1





Grupa: Zarejestrowani
Postów: 227
Pomógł: 1
Dołączył: 12.05.2002
Skąd: gdańsk

Ostrzeżenie: (0%)
-----


Witam, kolejnym moim problem jest niemożność skopresowania pliku źórdłowych.

Mam sklep osc, kompresuje go przez stadardowo funcje tego sklepu (ob_start, ob_flush), ale kompresuje tylko plik głowny - oczywiscie nie bierze resourcow np js css,
jakis sposob aby skompresowac calosć ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 7)
heaven
post
Post #2





Grupa: Nieautoryzowani
Postów: 92
Pomógł: 15
Dołączył: 21.10.2006

Ostrzeżenie: (0%)
-----


Hejka
znalazlem cos takiego

It is also possible to use ob_gzhandler to compress css and javascript files, however some browsers such as firefox expect content type text/css on css files.

To get around this send a content type header:
  1. <?php
  2. ob_start('ob_gzhandler');
  3. ?>
  4.  
  5. .... your css content ...
  6.  
  7. <?php
  8. header("Content-Type: text/css");
  9. header('Content-Length: '.ob_get_length());
  10. ?>
Go to the top of the page
+Quote Post
aren
post
Post #3





Grupa: Zarejestrowani
Postów: 25
Pomógł: 1
Dołączył: 8.03.2007

Ostrzeżenie: (0%)
-----


Wiec rozwiazanie typu (tylko przyklad):
  1. <?php
  2. ob_start('ob_gzhandler');
  3. include("/corefiles/header.php");
  4. include("/corefiles/styles/1/1.css");
  5.  
  6. /*
  7.   Tu kod
  8. */
  9. ?>

Nie bedzie gzipu na 1.php czy header.php ? Chyba - z calym szacunkiem - cos nie macie Panowie racji.
Go to the top of the page
+Quote Post
pieto
post
Post #4





Grupa: Zarejestrowani
Postów: 227
Pomógł: 1
Dołączył: 12.05.2002
Skąd: gdańsk

Ostrzeżenie: (0%)
-----


No racje po zaincludowaniu przez include oczywscie skompresuje sie,
ale nie jesli

<link rel="stylesheet" type="text/css" href="stylesheet.css">
i
<script language="javascript" src="javascript/general.js"></script>

nieprawdasz aren ?

ocykalem sobie 2 sposoby

1. includowaie php w we wszystkich plikach css i js
2. i lepszy przez mod_rewrite - skierowanie na php

moze jakis inny sposob ?
Go to the top of the page
+Quote Post
aren
post
Post #5





Grupa: Zarejestrowani
Postów: 25
Pomógł: 1
Dołączył: 8.03.2007

Ostrzeżenie: (0%)
-----


No rzeczywiscie, zwracam honor (nawet nie zdawalem sobie z tego sprawy). Jednak musi byc jakis inny sposob niz te dwa podane przez Ciebie...
Go to the top of the page
+Quote Post
Jabol
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 1 467
Pomógł: 13
Dołączył: 22.02.2003

Ostrzeżenie: (0%)
-----


zainteresuj się mod_gzip, wtedy nie będziesz musiał tego robić w php, apache zrobi to za Ciebie.
Go to the top of the page
+Quote Post
heaven
post
Post #7





Grupa: Nieautoryzowani
Postów: 92
Pomógł: 15
Dołączył: 21.10.2006

Ostrzeżenie: (0%)
-----


Hejka
oto rozwiazanie to inne (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
w pliku html piszesz
  1. <link rel="Stylesheet" href="stylesheet.php" type="text/css">

zwróć uwagę na rozszezenie php (stylesheet.php)

i teraz tworzysz ten plik tak
  1. <?php
  2. ob_start('ob_gzhandler');
  3. ?>
  4.  
  5. body {
  6. background-color:#ffffb9;
  7. margin:0px;
  8. }
  9. ........
  10.  
  11. <?php
  12. header("Content-Type: text/css");
  13. header('Content-Length: '.ob_get_length());
  14. ?>


dzieki temu bedzie wysylalo skompresowane pliki css i tak samo mozesz zrobic z js

Ten post edytował heaven 21.03.2007, 13:13:18
Go to the top of the page
+Quote Post
aren
post
Post #8





Grupa: Zarejestrowani
Postów: 25
Pomógł: 1
Dołączył: 8.03.2007

Ostrzeżenie: (0%)
-----


Nie glupie rozwiazanie heaven. Dobrze wykombinowales.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 19:37