Portrety Uliczne Nieznajomych - zobacz wyjątkową galerię portretów z warszawskich ulic
ZALOGUJ SIĘ
login:
hasło:
przypomnij hasło
załóż konto użytkownika
(i zobacz kilka porad gratis)
   
WYSZUKIWARKA I DZIAŁY
całe porady  tytuły
zaznacz działy do przeszukania
(brak wyboru = wszystkie działy)
PHP
MySQL >
PostgreSQL
SQLite
Perl
Java
XML
XSLT
XPath
WML
SVG
RegExp
Wyszukiwarki
Ochrona
VBScript
Google Plus
XHTML/CSS
JavaScript
Grafika
Flash
Photoshop
Windows
Linux
Bash
Apache
Procmail
E-biznes
Explorer
Opera
Firefox
Inne porady
   
KURSY, DOKUMENTACJE
Własne:
XHTML/CSS
JavaScript
ActionScript
WML, RSS, SSI
Pozostałe:
PHP
MySQL
Java API
więcej...
   
użytkowników online: 46
W CZYM MOGĘ POMÓC?


   
OPINIE UŻYTKOWNIKÓW
Gratulacje i dzięki! Trafiłem tu przypadkiem poszukując informacji na temat php+mysql. Wiele polskich stron powiela identyczne przykłady, klonuje te same kursy i lekcje... ten serwis okazał sie inny. Zasada "problem - rozwiazanie - wyjaśnienie" zdaje egzamin - zapewnia jasną, jednoznaczną i pewną pomoc w konkretnym przypadku. Porady są warte swojej ceny, przede wszystkim ze względu na przyjazną (także dla początkujących) formę i treść oraz bogate i stale powiększane zasoby. Polecam i pozdrawiam!

Kamil Dmowski
Polski Czerwony Krzyż

   
GALERIA FOTOGRAFII
   
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net

[Spis] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [X] [W] [Z]

session_cache_limiter

(PHP 4 >= 4.0.3, PHP 5)

session_cache_limiter --  Pobierz i/lub ustaw bieżący ogranicznik pamięci podręcznej

Opis

string session_cache_limiter ( [string ogranicznik] )

session_cache_limiter() zwraca nazwę bieżącego ogranicznika pamięci podręcznej. Jeśli podany został parametr ogranicznik, nazwa bieżącego ogranicznego zostanie zmieniona na nową wartość.

Ogranicznik pamięci podręcznej kontroluje nagłówki HTTP wysyłane do klienta. Nagłówki te ustalają zasady, według których zawartość strony może być przechowywana w pamięci podręcznej przeglądarki. Ustawiając ogranicznik pamięci podręcznej na nocache zabronimy jakiekolwiek zachowywanie strony po stronie klienta. Wartość public pozwoli na takie przechywanie. Ogranicznikiem może być też private, który jest troszkę bardziej restrykcyjny niż public.

W trybie private nagłówek Expire, który jest wysyłany do klienta, może spowodować nieoczekiwane działanie niektórych przeglądarek, między innymi Mozilli. Możesz uniknąć tego problemu używając trybu private_no_expire. Nagłówek Expire nie jest w tym wypadku wysyłany do klienta.

Notatka: private_no_expire zostało dodane w PHP 4.2.0.

Ogranicznik pamięci podręcznej w momencie wywołania skryptu jest zerowany do wartości domyślnej przechowywanej w session.cache_limiter. W związku z tym niezbędne jest wywołanie session_cache_limiter() dla każdego wywołania skryptu (i przed wywołaniem session_start()).

Przykład 1. Przykłady session_cache_limiter()

<?php

/* Ustaw ogranicznik pamięci podręcznej na 'private' */

session_cache_limiter('private');
$cache_limiter = session_cache_limiter();

echo
"Ogranicznikiem pamięci podręcznej jest teraz $cache_limiter<br />";
?>

Patrz także: session.cache_limiter.




User Contributed Notes

19-Oct-2005 05:11

The onLoad method of Actionscript's loadVars class was returning false in IE6 using SSL until I set --> session_cache_limiter("must-revalidate"); <-- on the receiving PHP script.


radu dot rendec at ines dot ro
18-Oct-2005 01:41

I've read the other comments and done some "reasearch" on my own. Using php's session mechanism and explicitly setting the "cache-control" header should not be mixed.

When session_start() is called, the "cache-control" and "pragma" headers are automatically set by php (to whatever value had been specified using session_cache_limiter()).

Explicitly setting those headers _before_ session_start() will have no effect, and explicitly setting them _after_ session_start() will overwrite the settings from session_cache_limiter().

If I had to deal with php sessions, I'd go for using session_cache_limiter() and leaving the headers alone.


03-Sep-2005 12:04

Andrei Chirila, andrei_chirila at yahoo dot com
12-Jan-2005 09:30
I played about an hour with the download and sessions. yes, to work you'll need session_cache_limiter("must-revalidate"); but this BEFORE session_start() if you want that your download start [IE problem]. Hope someone will need this someday

====

yes, somebody has needed this today :)

situation: trying to make a session based download management system complete with user login system that requries an authorized user to download some files, and hide all such files from non-authorized users. the user login, download center, and content management system of the site are all tied in to each other, making troubleshooting this headering stuff a headache.

problem: files being served are not accessible thru the regular site, since they are above the htdocs folder in apache, and so headering the file is required, and sessions do not work well with files being headered to the browser.

solution: the download center uses ob_start("");, then  session_cache_limiter("must-revalidate");, before the session_start();, then everything works well.

thank you very much! i was resorting to using a cookie to control this before because i could not figure out how to tie in sessions to the system before!


donovan at go4 dot com dot au
08-Aug-2005 03:41

IE6 'the file could not be written to the cache':

I tried all the other suggestions mentioned here but none of them worked.

I friend suggested header("Pragma: ");

This worked straight away!


snakes at ntica dot com
12-May-2005 11:28

Avoiding caching PHP pages:
After lot of tries and research this is the best combination of headers I've found that seems to work well even with the proxy of visitors that are using satellit connection.

<?
header
("ETag: PUB" . time());
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()-10) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time() + 5) . " GMT");
header("Pragma: no-cache");
header("Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate");
session_cache_limiter("nocache");
?>


Andrei Chirila, andrei_chirila at yahoo dot com
12-Jan-2005 03:30

I played about an hour with the download and sessions. yes, to work you'll need session_cache_limiter("must-revalidate"); but this BEFORE session_start() if you want that your download start [IE problem]. Hope someone will need this someday ...


justin at justintubbs dot com
07-Jan-2005 09:04

I have PHP 4.3 running on a Windows 2003 Server running IIS 6.0 also using SSL encryption for my pages.  I could not (for the life of me) figure out how to get IE 6.0/WinXPPro to recognize a set of HTML tables as an Excel spreadsheet export, and it was due to the header() variables I was using.  Hopefully these are helpful to others who are attempting the same type of export within PHP.

*This example builds on the previously submitted one, adding a few necessary headers.

<?php
   header
("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
  
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
  
header("Pragma: public");
  
header("Expires: 0");
  
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  
header("Cache-Control: public");
  
header("Content-Description: File Transfer");
  
  
session_cache_limiter("must-revalidate");
  
header("Content-Type: application/vnd.ms-excel");
  
header('Content-Disposition: attachment; filename="fileToExport.xls"');

  
// and after you start the session
  
session_start();
?>


pulstar at ig dot com dot br
24-Oct-2004 11:39

You can find more information about to control the cache in PHP at http://www.php.net/manual/en/function.header.php

If you have a dinamic website and want to allow your visitors to use the back button after they sent a form with the post method, the best combination I found was:

<?php

header
("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter("must-revalidate");

// and after you start the session
session_start();

?>

I try some combinations using header("Cache-Control: no-cache, must-revalidate"), but when clicking the back button, the last changes in the form back to their previous states. The combination above works fine with IE 6.x. I didn't test this with other browsers.

When I try something like session_cache_limiter("nocache, must-revalidate") it doesn't work. The page only updates when I used the browser's refresh button. In dynamic web sites this is not good. The content must be fresh after each click.

I didn't find these combinations like "private, must-revalidate" documented in the manual and I guess that something different from "none, nocache, private, public and private_no_expire" are resolved to "none" or something like that. One thing I notice is that in session_cache_limiter() it is "nocache", but in header() it is "no-cache". This may give us some clues about how session_cache_limiter() function works.

About caching, the perfect solution I think is to give the correct expiration date and time and also the right last-modified header for each element in the web site, when they are really updated. This means a lot of extra controls of course, but may worth in web sites with high overload.

The "public" option means that all available cache in proxies and clientes will be used, so this improves the speed of the web site and also reduces the used bandwidth. But without the right expiration and last-modified headers, you can use it only in static web sites.

The "private" option means that only the cache in clients will be used. This is good for a more sensitive data that can be stored locally in the browser cache. It have some benefits of the public option, but the same restrictions too.

The "nocache" (or no-cache?) option means that the HTML portion will not be cached, but the images, CSS and JS files will. This is good for dynamic websites because you still can use the power of cache without loose the refreshness after each click. These files can be updated when you open the web site or use the browser's refresh button.
I don't know why, but flash files are never updated when you click the refresh button. A common solution for this is to change the file name when you update the flash file.

The "no-store" option means that all the content will not be cached anyway, including images, CSS or JS files. I don't know if this applyes to flash files too, but is possible. This option must be used with very sensitive data. I think the SSL uses this by default.


misterp3d at hotmail dot com
18-May-2004 11:16

I had a problem using a FORM with POST method when user of my website was using the back button. The page requested a refresh to be able to see again the FORM.

To solve the problem I used :
<?php
session_cache_limiter
('private, must-revalidate');
?>

*You need to write this line before any output

Hope that will help some of you ;)

[P]


usenet at phord splat com
26-Mar-2004 05:44

Hey!  NickyBoy was right!

I looked all over google and his note was the only place that had it right.  But, there's a caveat.

I wrote up my results here:
http://www.phord.com/experiment/cache/


richard at izyn dot co dot nz
02-Mar-2004 03:17

I found that session_cache_limiter("none") works for me when I create PDFs  on the fly because session_cache_limiter("private") causes the browser(IE6) to cache the PDF indefinitely.


Mikko H

 

 
  © 1996-2012 & Reporter.plmiejscao serwisieabonamentwarunki korzystaniaRSSkontakt