A dervise travelling through Tartary, being arrived at the town of Balk, went into the king's palace by mistake, as thinking it to be a public inn, or caravansary. […] It happened that the king himself passed through the gallery during this debate, and, smiling at the mistake of the dervise, asked him how he could possibly be so dull as not to distinguish a palace from a caravansary? […] 'Ah, Sir,' said the dervise, a house that changes its inhabitants so often, and receives such a perpetual succession of guests, is not a palace, but a caravansary.'
Source: wiktionary