How to remove flash cache on a web site periodically - html

I'm using a flash rotating banner in my website which takes images and descriptions from an XML file.
I do changes to my XML very often... but in my local machine, the banner takes a day or two to get updated.
Although I can clear my local machine's cache, the problem still remains for other users who visit my web page..
is there a programmatic way in flash or in html to overcome this problem ? Maybe a server configuration? Please help me with this..
PS: below code works fine, but it clears out the cache completely...
i need to clear XMl cache after a specific time period.. please help.
var timestamp:Date = new Date();
xmlData.load("/flash/images.xml?cachebuster=" + timestamp.getTime());

If you want to clear the cache every day, use this:
var timestamp:Date = new Date();
xmlData.load("/flash/images.xml?cachebuster=" + timestamp.getMonth() + timestamp.getDate());

If you desperately need the XML to update continuously (like live-statistics) you can call the code each time your banner loops before populating your content.
In general, Sam's code is fine - often you don't need your flash to clear the XML after a time period - it only needs to clear each time the user views your banner.

Related

New MySQL query on each page refresh

I'm trying to to guarantee that fresh JSON is sent to my page every time a user clicks refresh. Currently, if the JSON is updated the webpage will not reflect the change until Apache is restarted.
I have tried the following approaches -
Create a nocache function and call the decorator in the page function
I have tried putting headers in my HTML
Using Command + Shift + R in Chrome for MacOS for a "hard" refresh
No good... I'm beginning to think I'm misunderstanding something. Can someone point out the error of my ways? I copy and pasted the code presented in those links. The first link even speaks about JSON specifically. I can show my exact code being used if desired, but like I said; copy and paste.
Maybe its not even a caching issue, I'm not sure, but I'm open to any ideas!
EDIT:
I know now that my no-cache headers ARE being passed to the HTML. The issue lies somewhere in that the Flask isn't asking MySQL for updated data every time the page is loaded, only when Apache is restarted. So even if fresh data is in MySQL DB it will not be displayed for the user unless Apache gets restarted.
I finally found another post on Stack Overflow regarding my question.
Turns out I need to make my DB connection and form the JSON in the same function. Before I was calling the data from the DB in a separate function and then referencing it to create JSON and pass it to the HTML in a different one. Now everything is inline see HERE.

If an ASP page takes too long to load, notify me

We have a Development box in our environment that will soon be moving to a Production environment. It is written in classic asp. One of the mandates as part of the disaster recovery plan is to ensure that if there is a problem loading the page, to notify the site admins. I know how to send the notification as we have a mail processor which is used to send out communications, but I am looking for help on how to do sort of like an IF statement, that if the page hasn't finished loading in x seconds, to email the site admins and continue loading the page until either it completes loading or times out. Again, we are not having any issues as of now, but we need to have something in place should there be any future problems. Again, this is done in classic asp.
So an example (30 being seconds to load):
If ServerScriptTimeout > 30 Then
response.write "Page is taking longer to load admins, please investigate"
Else
End If
Would something like this work or even be possible?
We use IIS7 on our Server
Thank you in advance for ur help.
UPDATE - just to add. We already have splash pages and notifications ready should there be a connection issue with one of our database connections. It validates the connection and then does a test query. If either of those fail, it provides the site admins with an update. I would like a similar option for page load time. I already have a script timeout in place, but wasn't sure if the script time out can work with an if statement to do something after x seconds passes before the timeout is triggered.
The best way will be to turn on IIS Logging and make sure you enable the time-taken, which is recorded in milli-seconds.
Now you can then either create a program or log parsers to monitor the IIS logs or use an IIS Log monitoring software and just set up alerts to page out if the time-take is over 30000 milliseconds.
There are numerous tools that do this, just do a search for one that will fit your needs.
Doing it in the code itself, if it times out then you will never get the alert, so I don't think that's the option you're looking for.
One option some sites use is for another application to regularly do a GET on landing page and if it fails to load or takes to long to send an alert.
There are plenty of third party services that offer this, search for "page availability test", or if you want it internal it would not be that hard to write. But the key point is that it has to be external to the IIS server.
I think I might have figured this out. Please provide your feedback on this if you wish to.
'Beginning of the page`
Starttime = Timer()
Do Until i=5382343
i=i+1
Loop
'Body of the page here
'at the bottom, type this in
TimeTest = (Timer - Starttime)
If TimeTest > 30.500000 Then
response.write "SLOW, Admins Notified"
Else
response.write "FAST"
End If
Response.Write("<br>The page was generated in : " & (Timer - Starttime) & " seconds.")

FPDF session variables

I have a web application that I've built on Wordpress version 4.1.1, I'm using PHP 5.4.22 and MySQL 5.5.42-cll.
The application collects user entry via form input fields, through a series of 4 consecutive pages, and stores to session variables. On the last page, there is a print to PDF feature that displays the customized PDF for user download. This PDF is generated via FPDF.
I had this feature working and am not sure what change, or auto-update in wordpress could've caused this to stop working. But I have troubleshot and narrowed the problem down to this:
The session variables aren't making it to the FPDF PHP files. I'm able to verify that the session variables remain on the page prior by printing them to the page. Again, I didn't change any of the code in the FPDF files or data input pages.
Please help if you can. I'm not certain what the problem may be.
Additional Info:
Around the same time this error was found, I was working on forcing SSL throughout wordpress. I ended up using the plugin WordPress Force HTTPS. I speculated this could've over-wrote something, but I'm not sure. The code within this plugin is simply:
function toz_force_https () {
if ( !is_ssl() ) {
wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 );
exit();
}
}
add_action ( 'template_redirect', 'toz_force_https', 1 );
Any assistance would be greatly appreciated!
I found the answer. Please forgive my oversight, this may be a super simple answer but I'm posting it so someone else doesn't go through the same frustration.
All of my session variables were stored on
https://www.example.com
and I was launching my FPDF via
https://example.com
I learned the hard way that Session variables in PHP are lost when changing the domain. Hope this saves someone some time.

Web Application Updates: Caching old app

I've created a Grails web application and put it live for users to use. It makes use of caching + backbone tpl's etc.
The issue is, when I make changes to html/css and put the new version live: users can only see these updates if they clear their cache. How can I get it so I can force users to fetch a new copy when I make updates to these static files. I've thought of the following:
1 - Make http headers with expire set to midnight every night (so each day they fetch the static data again in the morning) - this would work nicely.
2 - Append a version to each static file I update.. for example main-v1-1.css and when I update this, change it to main-v1-2.css etc...
Any information would be handy, because currently when I push any slight html/css updates.. users are not seeing these new updates unless I get them to clear cache/refresh browser.
Have you tried using cache-headers plugin? It can help you to control how the browser cache your contents here

Trigger a web page refresh

I am working on an android application that will show an html page that contains only some text on a tablet device. The device will be on and showing this page for long periods of time(several hours). The text on this page will get changed from time to time.
To change the text on the page I've made a separate second page that contains a form to enter the new strings into and a submit button that uses ASP to generate a new version of the first page and save it over top of the original copy. This is set up and working great, but it means that I have to refresh the page very frequently in order to ensure I am always showing the latest message.
I am looking for a way that I could trigger a refresh only when a new message is saved. That way I will not have to refresh the page every minute but the new message will still get shown in a timely manner.
No dice, HTTP is built as a stateless, pull-only (ignoring file uploads) protocol. The server can't push data to the client, the client has to actually poll the server for new information.
However, you can minimize the overhead of this by using an AJAX call with JSON as the transport protocol instead of generating entire web pages and update your page on the client side. The overhead should be minimal for almost any application.
If you were just a web-app, I would suggest looking into the various Comet frameworks.
http://www.google.com/search?q=comet+framework
But, since you have an Android shell around it, you can make a Socket connection back to your server and have the server signal when it's time to refresh. It's essentially the same, but you don't need to code up the push in JavaScript if you're more comfortable in Java.