Return URL with JavaScript that Prevents Loading of Cached Pages

HTML and JS logos

If you want to force a page to reload from the server rather than getting a cached copy, one way to do it is to append a query string to the URL.

If you want your web application to generate URLs that have this functionality, the code below can be implemented using JavaScript. Inside a file called BrowserUtility.js, insert this code.

function BrowserUtility()
{
	this.addNoCacheTimestamp =
		function(sUrl)
		{
			var ts = 'noCacheTS=' + (new Date()).getTime();
			sUrl = sUrl.trim();
			var nQIndex = sUrl.indexOf('?');
			sUrl+=(nQIndex==-1)?'?':(nQIndex===sUrl.length-1)?'':'&';
			return sUrl+=ts;
		};
};

var browserUtility = new BrowserUtility();

Once this is loaded, the function can be called like this, where the variable sUrl stores a URL:

sUrl = browserUtility.addNoCacheTimestamp(sUrl);

If the variable sUrl initially contained “http://example.com”, the returned string would be something like “http://example.com?noCacheTS=201808081203”.

Another option, if you did not want to use the current time as the query string value, would be to use a random number function instead.

(This is a snippet of code that I didn’t write – it was authored by my friend and colleague Jeff Konicky.)

Executing Stored Procedures in Loops Using PL/SQL Tables

Oracle Database PL/SQL

I needed to be able to run a stored procedure once for each item in a list. In Microsoft SQL Server, I would probably do this with a table variable and a cursor, and the code would look something like this:

DECLARE @wo_table TABLE (wo_id VARCHAR(10) NOT NULL);
DECLARE @wo_id VARCHAR(10);

INSERT INTO @wo_table (wo_id) VALUES
('123456')
,('234567')
,('345678')
,('456789')
,('567890');

DECLARE wo_cursor CURSOR FOR
SELECT wo_id FROM @wo_table;

OPEN wo_cursor;
FETCH NEXT FROM wo_cursor INTO @wo_id;
WHILE @@FETCH_STATUS=0
BEGIN
	EXEC dbo.MyStoredProc @wo_id;
	FETCH NEXT FROM wo_cursor INTO @wo_id;
END;

CLOSE wo_cursor;
DEALLOCATE wo_cursor;

However, PL/SQL does not have table variables. While an option like a global temporary table could work, I decided that a PL/SQL table was a better solution.

Declare the PL/SQL table type, instantiate the PL/SQL table with the list of values (strings, in this case), then loop over the PL/SQL table, running the stored proc with each value. Notice that the “EXECUTE” keyword is missing. It is not only unnecessary in this context; it will not work here.

Below is the completed code:

DECLARE
  TYPE wo_table_type IS TABLE OF VARCHAR2(10);
  wo_table wo_table_type := wo_table_type(
    '123456'
    ,'234567'
    ,'345678'
    ,'456789'
    ,'567890');

BEGIN
  FOR i IN 1..wo_table.COUNT LOOP
    PackageName.MyStoredProc(wo_table(i));
  END LOOP;
END;

Problems with iOS 12 Beta Screen Time

iOS 12 logo

As should be obvious, putting a beta version of iOS on your primary iPhone may not be a wise choice – especially if you’re not a developer hunting for bugs. Even so, the iPhone 6s I bought for my daughter from Gazelle came with iOS 12 beta 3 loaded onto it.

iOS 12 Software Update screen

When I saw this, I was surprised, but I figured it wouldn’t be too big of a deal. However, I quickly discovered when setting up parental controls that things had changed. What was once called Restrictions, was now called Screen Time, and many things inside there were not where I expected them to be. This was, admittedly, the first time I had looked at iOS 12.

I began trying to set up Screen Time like I had restrictions on iOS 11 on her iPad. I also was able to get Disney’s Circle Go installed for additional control.

Once I thought I had everything set correctly, I tried to set up her Mail app with her Gmail account. It wouldn’t connect to Google’s accounts page for Gmail because the website was apparently blocked. I then began turning off restrictions – first Circle Go, then Screen Time. Still a no go. At this point, Safari wouldn’t even open.

I started checking to see if Screen Time in the beta had known bugs. Sure enough, it did.

At this point, I decided it was time to load iOS 11.4, so I did, with these instructions.

All is well now!