[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

How to Cache a page for 24 hours in Javascript

Luis

7/7/2015 10:42:00 AM

I need to use Javascript to implement caching.
I am using Apache as my web server on a CentOS linux server.
I am using PHP for dynamic content in my web pages.

-I need to ensure my website pages are cached for 24 hours after they are first loaded.
-I need to ensure my website images are cached for one week after they are first loaded.
-I need to ensure my website videos are cached for one week after they are first loaded.


What is the recommended way to do this?

Any feedback/recommendations links to best practices would be appreciated.
10 Answers

Evertjan.

7/7/2015 11:18:00 AM

0

On 07 Jul 2015, you wrote in comp.lang.javascript:

> I need to use Javascript to implement caching.

Why Javascript?
You mean caching on the server?

Why "need" and not just "want"?
Is this a school or other learning assignment?

> I am using Apache as my web server on a CentOS linux server.
> I am using PHP for dynamic content in my web pages.

So why not PHP on your server?

> -I need to ensure my website pages are cached for 24 hours after they
> are first loaded. -I need to ensure my website images are cached for
> one week after they are first loaded. -I need to ensure my website
> videos are cached for one week after they are first loaded.

"First loaded"?
You still mean cashed on the server?

> What is the recommended way to do this?

Whose recomendation are you referring to?

> Any feedback/recommendations links to best practices would be
> appreciated.

"best" being a dirty word in Qs like these.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Michael Haufe (\"TNO\")

7/7/2015 3:17:00 PM

0

On Tuesday, July 7, 2015 at 5:42:18 AM UTC-5, Luis wrote:
> I need to use Javascript to implement caching.
> I am using Apache as my web server on a CentOS linux server.
> I am using PHP for dynamic content in my web pages.
>
> -I need to ensure my website pages are cached for 24 hours after they are first loaded.
> -I need to ensure my website images are cached for one week after they are first loaded.
> -I need to ensure my website videos are cached for one week after they are first loaded.
>
>
> What is the recommended way to do this?
>
> Any feedback/recommendations links to best practices would be appreciated.

Just use PHP for this and set the appropriate headers.

This is off-topic in this forum.

Luis

7/7/2015 10:44:00 PM

0

Hi Evertjan,
I need to cache on the client NOT on the server.
It's a corporate mobile application with lots of files/video content that I am working on.
The content is pretty much static daily for each group within a large department.

On Tuesday, July 7, 2015 at 7:17:42 AM UTC-4, Evertjan. wrote:
> On 07 Jul 2015, you wrote in comp.lang.javascript:
>
> > I need to use Javascript to implement caching.
>
> Why Javascript?
> You mean caching on the server?
>
> Why "need" and not just "want"?
> Is this a school or other learning assignment?
>
> > I am using Apache as my web server on a CentOS linux server.
> > I am using PHP for dynamic content in my web pages.
>
> So why not PHP on your server?
>
> > -I need to ensure my website pages are cached for 24 hours after they
> > are first loaded. -I need to ensure my website images are cached for
> > one week after they are first loaded. -I need to ensure my website
> > videos are cached for one week after they are first loaded.
>
> "First loaded"?
> You still mean cashed on the server?
>
> > What is the recommended way to do this?
>
> Whose recomendation are you referring to?
>
> > Any feedback/recommendations links to best practices would be
> > appreciated.
>
> "best" being a dirty word in Qs like these.
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Luis

7/7/2015 10:47:00 PM

0

Hi Michael,
Why the round trip each time the page is loaded?
Engineers access the same page multiple times per appointment.
Why not store the page on the client for the rest of the day?


On Tuesday, July 7, 2015 at 11:17:17 AM UTC-4, Michael Haufe (TNO) wrote:
> On Tuesday, July 7, 2015 at 5:42:18 AM UTC-5, Luis wrote:
> > I need to use Javascript to implement caching.
> > I am using Apache as my web server on a CentOS linux server.
> > I am using PHP for dynamic content in my web pages.
> >
> > -I need to ensure my website pages are cached for 24 hours after they are first loaded.
> > -I need to ensure my website images are cached for one week after they are first loaded.
> > -I need to ensure my website videos are cached for one week after they are first loaded.
> >
> >
> > What is the recommended way to do this?
> >
> > Any feedback/recommendations links to best practices would be appreciated.
>
> Just use PHP for this and set the appropriate headers.
>
> This is off-topic in this forum.

Christoph M. Becker

7/7/2015 10:54:00 PM

0

Luis wrote:

> I need to cache on the client NOT on the server.
> It's a corporate mobile application with lots of files/video content that I am working on.
> The content is pretty much static daily for each group within a large department.

Let the browser do the caching; don't do it yourself (unless you have
very specific reasons).

--
Christoph M. Becker

Michael Haufe (\"TNO\")

7/8/2015 2:32:00 AM

0

On Tuesday, July 7, 2015 at 5:46:38 PM UTC-5, Luis wrote:
> Hi Michael,
> Why the round trip each time the page is loaded?
> Engineers access the same page multiple times per appointment.
> Why not store the page on the client for the rest of the day?

That's not how caching works.

Set the appropriate headers from the server and let every point in between do its job.

Evertjan.

7/8/2015 7:23:00 AM

0

Luis <roy1mos@gmail.com> wrote on 08 Jul 2015 in comp.lang.javascript:

> I need to cache on the client NOT on the server.

[please do not top post on usenet]

I suspect you mean browser with "client"?

Browser cashing has a special meaning,
that is just for the benefit of a quick reloading of a page.
[yes, I know browser-security can be swithed off,
please know what you are doing!]

Perhaps it is that you want to "backup" a website by "catching" all new
content for a while [days/weeks]?

I would not use a browser for that, as a browser is made secure by NOT being
able to have access to your HDs.

Better use wscript/jscript on your pc for that,
using Xmlhttp, Scripting.FileSystemObject and perhaps a database.
Javascript can be used there.

Or, on an ASP platform on a different server than your PHP-one,
also using Xmlhttp, Scripting.FileSystemObject and perhaps a database.
You can do that with serverside Javascript.

Both can be triggered to do this job say several times a day.

> It's a corporate mobile application with lots of files/video content
> that I am working on. The content is pretty much static daily for each
> group within a large department.

"static daily"??

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Erwin Moller

7/8/2015 10:08:00 AM

0

On 7/8/2015 12:46 AM, Luis wrote:
> Hi Michael,
> Why the round trip each time the page is loaded?
> Engineers access the same page multiple times per appointment.
> Why not store the page on the client for the rest of the day?
>

[Please don't top post]

I think you need to read up a little on the mechanics of caching (and
some browser-bugs).
You can start in many places, so here is a random one:

http://stackoverflow.com/questions/4480304/how-to-set-http-headers-for-cac...

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens

Thomas 'PointedEars' Lahn

7/8/2015 10:13:00 AM

0

Erwin Moller wrote:

> On 7/8/2015 12:46 AM, Luis wrote:
>> Why the round trip each time the page is loaded?
>> Engineers access the same page multiple times per appointment.
>> Why not store the page on the client for the rest of the day?
>
> [â?¦]
> I think you need to read up a little on the mechanics of caching (and
> some browser-bugs).
> You can start in many places, so here is a random one:
>
> http://stackoverflow.com/questions/4480304/how-to-set-http-headers-for-cac...

For me, the standard text on Web caching still is

<https://www.mnot.net/cache...

I notice that it has been redesigned since my last visit, and is better
readable now.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.

Erwin Moller

7/8/2015 1:21:00 PM

0

On 7/8/2015 12:13 PM, Thomas 'PointedEars' Lahn wrote:
> Erwin Moller wrote:
>
>> On 7/8/2015 12:46 AM, Luis wrote:
>>> Why the round trip each time the page is loaded?
>>> Engineers access the same page multiple times per appointment.
>>> Why not store the page on the client for the rest of the day?
>>
>> [â?¦]
>> I think you need to read up a little on the mechanics of caching (and
>> some browser-bugs).
>> You can start in many places, so here is a random one:
>>
>> http://stackoverflow.com/questions/4480304/how-to-set-http-headers-for-cac...
>
> For me, the standard text on Web caching still is
>
> <https://www.mnot.net/cache...
>
> I notice that it has been redesigned since my last visit, and is better
> readable now.
>

That page surely looks like a very decent in-depth explanation.
Bookmarked!

Thank you.

Regards,
Erwin Moller

--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens