Though its exact function has varied from period to period, the antiquity of the Iranian caravanserai is not in doubt. However, the caravanserai as a structural form, as we know it today, is the result of geographic, political and economic influences reaching back to the seems largely due to the fact that several structures have served a similar function – the protection of travel erss.
Before the Islamic conquest of Persia, Nestorian, Christians and Buddhists had monasteries with hostels attached, and with the advance of Islam came the erection of robats. The word robat itself (from the Arabic verbal from “he ties up”) has lent itself to a multiplicity of uses, from a ‘frontier post against the infidel’ to a ‘Sufi community house.’ The word first signified a fort on the Islamic frontier; since war was considered primarily a struggle for the faith, such garrisons have a religious as well as a military character. 
Gradually the meaning enlarged to include postal stations, caravanserais and places of refuge.
It was used by Naser khosrow in the Safar Nameh to refer to rest houses that had no religious significance. The word caravanserais is derived from caravan or caraban and sarai. Caravan means a band of travellerss journeying together; this they also term in Iran Qafeleh, that is to say a company of returners, serai signifies a place or a spacious inn (whence comer seraglio).
Both  words, caravan and serai, originated in ancient Iran. With the Islamic period came several words like caravan – khaneh (caravan house), caravan – gah and caravan  - gah, all with the same meaning. Graduaily after Islam, other words such as robat, khan and inn came to be used instead of caravanserai. 
Caravan Routes And Caravanserais 
Basically, of course, a route can be described as merely a path between two inhabited nuclei. Its upkeep, depending on historical factors, will be regulated by its social or economic importance. Iran, both by virtue of her own cultural donation to the world and her geographical position between east and west has long recognized the importance of secure and well-kept roads. Although we know that the history of trade and travel in Iran goes back to remote antiquity, the camel caravan, a part of the worlds lore, served for centuries as the main method of transport. Gradually, however, fast communication grew up and a network of roads spread across the land. This growth went largely hand in hand with the growth of a strong centralized government.
At the height of the Persian Empire, Iran’s communication system was justly famous and secure, and well-kept roads were an essential element in the prosperity of the country. 
Outline History Of The Iranian Caravanserai
Think, in this battered caravanserai whose
Portals are alternate night and day how 
Sultan after sultan with his pomp abode his
Hour or two, and went his way

As we have said, no trace remains of Achaemenian caravanserais, the earliest recorded, so we can only guess at their from. That they were built of mud brick seems possible but their degree of sophistication is a matter of conjecture, bearing in mind their role, which was largely limited to stabling mounts for post-riders. It seems likely therefore that they consisted of nothing more than a wall enclosing a courtyard, a well and a small dwelling- place for the liveryman and his family.   

Iranian caravanserais have to be examined both from the architectural and also from the decorative and detail arrangement point of view. 
As for the architectural examinations, it is first of all their ground plan that has to be taken into consideration. 
According to their ground plan the following types can be distinguished: 
1)      The mountainous type. 
2)      The Persian gulf (low sea shore) type. 
3)      The miscellaneous type. 
4)     The central court with iwans type. Type four also can be
       divided to several groups such as: 
A)    Caravanserais with two iwans. 
B)    Caravanserais with four iwans. 
C)    Circular type. 

Octagonal, polygonal types. 

Golden Age of iranien Caravanserais
The Safavid period was one of the most famous and glorious of the native dynasties of Iran since the introdution of Islam.
In the sixteenth century the artistic culture of Iran entered a new period of splendour and magnificence. Under the enthusiastic safavid dynasty, art reached the acme of its manifold expression in textiles, ceramics, painting and above all, in architecture, of which many glorious examples remain to be seen in Iran, especially in Isfahan.
In Iran most caravanserais are popularly attributed to Shah Abbas the great whose name is justly associated with the golden age of the caravanserais. As morier says:
“Nothing indeed can equal the truly royal establishments which shah Abbas the great maintained throughout his dominions for the accommodation of strangers.”