使用友好的URL,以避免缓存问题缓存、友好、问题、以避免

2023-09-02 01:15:54 作者:- 缺口@

在我的应用程序(*)我有时需要打开(默认用户浏览器)的URL与一些参数。

In my application (*) I sometimes needs to open (in the default user browser) a URL with some parameters.

如: HTTP://www.mySite。 COM / myPage.php P1 =参数1&放大器; P2 =参数2和放大器; P3 =参数3

在某些计算机上,我有缓存的问题,就算我送不同的参数,在浏览器中打开的页​​面与旧的参数。

On some computers, I had cache problem, even if I send different parameters, the browser opened the page with the old parameters.

我尝试添加时间戳作为第一个参数:

I tried to add time-stamp as the first parameter:

如:的http://www.mySite.com/myPage.php?pXXX=XXX&p1=param1&p2=param2&p3=param3 在其中XXX = Now.ToString(ssmmHHddMMyy)

但尽管如此,在某些计算机上它并没有解决这个问题。

but still, on some computers it did not solve the problem.

我不知道是否使用友好的URL将有助于避免高速缓存问题,为所有用户,所有的浏览器,所有默认设置等。

I wonder if using friendly URLs will help avoiding the cache problem for all users, all browsers, all default settings etc.

如: http://www.mySite.com/myFalsePage/param1/param2/参数3

[我的源代码使用友好的URL:

[ My source for using friendly URLs:

的http://techie-buzz.com/how-to/create-seo-friendly-urls-using-mod-rewrite-and-php-part-1.html http://techie-buzz.com/tips-and-tricks/create-seo-friendly-urls-with-mod-rewrite-and-php-part-ii.html http://techie-buzz.com/how-to/create-seo-friendly-urls-using-mod-rewrite-and-php-part-1.html http://techie-buzz.com/tips-and-tricks/create-seo-friendly-urls-with-mod-rewrite-and-php-part-ii.html

]

您在使用传递参数的这种方法发现任何DIS-优势?

谢谢

Atara。

(*)我的应用程序是一个exe文件(VB .NET) 之一的应用程序的菜单选项被打开的URL,使用用户默认浏览器:

(*) My application is an exe file (VB .Net) One of the menu options of the application is opening the URL, using the user default browser:

 '-- Create temporary *.url file and open it
  Try
    Dim line1 As String = "[InternetShortcut]"
    Dim line2 As String = "URL=" & sUrl
    Dim dst As String = GetSystemPathTemp() & "myAppTemp.url"

    Dim sw As New System.IO.StreamWriter(dst, False)
    sw.WriteLine(line1)
    sw.WriteLine(line2)
    sw.Close()

    System.Diagnostics.Process.Start(Chr(34) & dst & Chr(34))   

的URL是一个形式中,所述参数是一些形式的字段,以便用户不会有键入它们。

The URL is a form, the parameters are some of the fields of the form, so that the user wont have to type them.

一般用户填写-在形式和重新定向到一个谢谢你的页面。

Usually the user fills-in the form and re-directed to a "Thank you" page.

我的问题:下一次用户点击菜单,打开网址形式,应该有不同的字段值的形式,根据目前的应用阶段,但在某些计算机用户浏览器的第一个URL被缓存,并在此之后,所有形式都充满了初始场,因此用户需要手动编辑它们(如果​​他注意到了这个问题),否则我得到的表单结果与非准确的信息 - 新用户的音符previous-错字段值。

My problem: The next time the user clicks the menu, and opens the URLform, there should be different field values in the form, according to the current application stage, BUT on some computersusersbrowsers the first URL is cached, and after that, all forms are filled with the initial fields, so the user needs to manually edit them (If he noticed the problem), otherwise I get the form results with non-accurate information - the new user notes with the previous-wrong field-values.

我的表单页面现在开始 -

My form page now starts with -

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");   // Date in the past

直到今天,它开始与下面的所有选项 -

Until today, it started with all the following options -

<?php
//disable all browser caching MUST BE FIRST LINES WITH NO PRECEEDING SPACES ETC
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

文件myAppTemp.url被更新,但浏览器打开旧链路。

The file "myAppTemp.url" is updated, but the browser opens the older link.

推荐答案

解决缓存问题的网址是不是要走的路。该URL应该重新present访问内容的方法,仅此而已。

The URL to solve a cache problem is not the way to go. The URL should represent a method to access the content, and nothing more.

在最后,你将永远无法彻底解决了客户端缓存,因为他们可以为所欲为。然而,随着一些无意义的标题,你会就好了。

In the end, you will never be able to completely resolve the clients caching, as they can do whatever they want. However, with some sensical headers, you will be just fine.

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

来源: http://php.net/manual/en/function.header。 PHP