The legend of the Seven Sleepers exists in hundreds of versions. There is the Christian version, which thinks the seven sleepers are Christian martyrs and Saints, generally called the Seven Sleepers of Ephesus. The Islam knows the same story, Aṣḥāb al-Kahf (those of the cave), which is told in the Holy Quran in Surah Kahf. The story is either the retelling of older legends or the base of newer legends. Some of the basic concepts or memes seem to be universal.
Decius came to Ephesus between 249 and 251 AD to enforce his laws against Christians. They were very hard and meant persecution. Seven noble young men, named Maximillian, Jamblichos, Martin, John, Dionysios, Exakostodianos, and Antoninos, were found to be Christians. The emperor gave them a short time for consideration, until he returned to Ephesus. So they gave their property to the poor, took only a few coins with them and went into a cave on Mount Anchilos to pray and prepare for death. When they heard of his return they said their last prayer in the cave and then fell asleep. When found asleep in the cave Decius ordered to bury them alive by sealing the cave with huge stones. A Christian came and wrote on the outside the names of the martyrs and their story.
Years passed, the Roman Empire became Christian, and Theodosius reigned. There are two Theodosius, so it may have happened between 150 and 200 years later. A rich landowner named Adolios had the Sleepers' cave opened, to use it as a cattle-stall. The sleepers awoke, thinking they had slept only one night, and sent Diomedes to the city to buy food, that they may eat before they give themselves up. Diomedes came into Ephesus and was amazed to see crosses over churches. People could not understand where he got money coined by Decius. Finally they learned that the last thing he knew was Decius's reign. The bishop and the prefect went up to the cave with him, where they found the six others and the inscription. Theodosius was informed, he came and the sleepers told him their story.
At this time some heretics denied the resurrection of the body, but every one rejoices at this proof of resurrection. The sleepers, having improved the occasion by a long discourse, then died praising God. The emperor wanted to build golden tombs for them, but they appear to him in a dream and ask to be buried in the earth of their cave. The cave is adorned with precious stones and a great church built over it. Every year the feast of the Seven Sleepers is held.
Symeon Metaphrastes (q.v.) in his "Lives of the Saints" for the month of July.
This legend was originally of Greek origin and the version of Symeon Metaphrastes is probably the most original written version. But this kind of legends is rather common. Sleepers in caves are found in all times and all countries, there are similar stories in the legends of King Arthur or the sleeping Emperor Barbarossa. The fact that you go to a magic place and loose centuries, you return after a day and hundreds of years are gone, is really common and found worldwide. There are Celtic fairy legends and German legends. Also the fact that they return seemingly unharmed and unchanged, but die afterwards in a few days or hours. Another meme which is quite common.
Later the story was occupied by the Christians as a Martyrs and Saints story, but it never made it into the Bible. Really strange is, that the same story is told in the Quran in Surah Kahf, chapter 18. In this version a dog accompanied the youths into the cave and kept watch. Alah let them all sleep for 300 years. In Arabic the seven sleepers are called أشابي الكهف (Eshab-ı Kehf, Ashâb-ı Kehf, People of the Cave). That's why Seven Sleepers Caves are called Ashâb-ı Kehf in the moslem part of the world.
However, there is a specialty with this story. For some reason a lot of people actually believed it really happened, and as a logic conclusion the cave actually existed. As a result people were looking for the cave for centuries. And they found it. Several times. We listed all caves which are definitely the true seven sleepers caves. All the others are fakes.